测试成功率未显示在dotnet项目的声纳单元测试小部件中

时间:2017-11-02 16:34:20

标签: c# msbuild sonarqube xunit sonar-runner

我在c#dot net项目上为msbuild运行了sonar runner。在下面运行之后是我在单元测试小部件中得到的结果,

overall unit test result

未显示单位测试成功率。在进一步检查的同时,我发现每个文件的单元测试也没有显示如下。

unit test result for each file 在执行此操作时,我已按照Unit Test Execution Results Import (C#, VB.NET)文档页面进行操作。我已执行下面的shell命令来运行声纳运行器

SET dotnet="C:\Program Files\dotnet\dotnet.exe"
SET opencover=C:\Users\lakshmanu\.nuget\packages\opencover\4.6.519\tools\OpenCover.Console.exe 
SET targetargs="test -f netcoreapp2.0 -c Release test/Services/UnitTest/UnitTest.csproj"  
SET filter="+[Test.MyTest.*]* -[*.Test]* -[xunit.*]* -[another]*"  
SET coveragefile=Coverage.xml

dotnet restore %WORKSPACE%\Myproj\My.API

MSBuild.SonarQube.Runner.exe begin /k:"test" /n:"test" /v:"1" /s:%WORKSPACE%\SonarQube.Analysis.xml /d:sonar.cs.opencover.reportsPaths="Coverage.xml" /d:sonar.cs.xunit.reportsPaths="D:\sources\test\Services\UnitTest\XUnitResults.xml"

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" Myproj.sln /t:Rebuild

REM Run code coverage analysis  
%opencover% -oldStyle -register:user -target:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" -targetargs:"test\Services\UnitTest\bin\Debug\netcoreapp2.0\UnitTest.dll /Framework:FrameworkCore10" -filter:%filter% -output:%coveragefile% -skipautoprops -hideskipped:All
cd test\Services\UnitTest\
dotnet xunit -xml XUnitResults.xml
cd ..\..\..

MSBuild.SonarQube.Runner.exe end

测试是使用xunit框架编写的。 Sonarqube版本是5.6.6。 有关为什么没有显示每个文件的测试成功率或单元测试的任何线索?

更新

谷歌搜索时我发现this question,根据那个和sonarqube文档,目前不支持每个文件的单元测试数。

1 个答案:

答案 0 :(得分:1)

SonarQube根本不会跟踪这些指标。

理论上,您的单位测试成功率应始终为100%。任何不足都应该使构建失败并抢占分析。

相关问题