Dotnet 测试覆盖率显示为 0%

问题描述 投票:0回答:0

我们正在使用:SonarQube 开发者版本:9.4.0.54424 我们注意到所有存储库的覆盖率报告显示为 0.0%。 我们不确定如何解决这个问题,任何人都可以帮助我们解决这个问题。 enter image description here

我在为 Sonar 运行 github 操作工作流程时看到以下错误:

15:50:31.476 将 Roslyn 分析器附加文件写入

/home/runner/work/*********/*******/.sonarqube/conf/vbnet/SonarLint.xml…

15:50:31.48 处理分析缓存

15:50:31.48 从 SonarQube 9.9 或更高版本开始可以使用增量 PR 分析。

15:50:31.52 预处理成功

/home/runner/work/_temp/ee5356df-6ed7-4aa8-9ae7-6e4d947bcd5e.sh:第 11 行:

/d:sonar.cs.vscoveragexml.reportsPaths=./tst/Infrastructure.Tests/TestResults/coverage.opencover.xml: 没有那个文件或目录

错误:进程已完成,退出代码为 127.

GitHub 操作流程定义如下:

- name: SonarQube Begin
    run: |
     
     #dotnet add package coverlet.collector --version 3.2.0
     
     dotnet tool install --global coverlet.console
     
     dotnet tool install --global dotnet-sonarscanner
            
     
     dotnet sonarscanner begin /k:"**********" /d:sonar.login=${{ secrets.SONAR_TOKEN }} /s:$GITHUB_WORKSPACE/SonarQube.Analysis.xml /d:sonar.verbose=true
     
     /d:sonar.cs.vscoveragexml.reportsPaths=./tst/Infrastructure.Tests/TestResults/coverage.opencover.xml /d:sonar.verbose=true
  
     dotnet build --no-incremental /d:sonar.verbose=true

     coverlet .\tst\Infrastructure.Tests\bin\Debug\net6.0\Infrastructure.Tests.dll 
     
     --target "dotnet" --targetagrs "test --no-build" -f=opencover -o="coverage.xml" /d:sonar.verbose=true

    - name: Build
    run: dotnet build

    - name: SonarQube end
    run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 

我已将测试结果文件上传到 github(位置):./tst/Infrastructure.Tests/TestResults/coverage.opencover.xml

SonarQube.Analysis.xml 文件,我已经更新为图像。

SonarQube.Analysis.xml

任何人都可以帮助我们解决问题。

谢谢, 阿尼尔·库马尔

.net sonarqube code-coverage sonarqube-scan
© www.soinside.com 2019 - 2024. All rights reserved.