nUnit的结果不会显示在SonarQube中

时间:2017-10-10 12:23:54

标签: jenkins msbuild sonarqube nunit-3.0

我正在使用SonarQube和Jenkins。在Jenkins,我用nUnit检查单元测试,用opencover检查覆盖率。 opencover的报告显示在Sonar中,但 nunit的报告不是

Coverage is displayed

Unit tests are not displayed

我按照说明:Analysing with SonarQube Scanner for JenkinsUnit Test Execution Results Import

我的“为MSBuild开始分析和SonarQube”args:

/d:sonar.sources="Foo.Bar.Business, Foo.Bar.Data, Foo.Bar.Web, Foo.Bar.FileGen, Foo.Bar.FileInt, Foo.Bar.Revision"
/d:sonar.binaries="Build/Foo.Bar.Business.dll, Build/Foo.Bar.Data.dll, Build/Foo.Bar.Web.dll, Build/Foo.Bar.FileGen.exe, Build/Foo.Bar.FileInt.exe, Build/Foo.Bar.Revision.exe, Build/Foo.Bar.TableauDeBord.exe"
/d:sonar.exclusions="Foo.Bar.Web/Scripts/JQuery/**/*, Foo.Bar.Web/Scripts/MomentJS/**/*, Foo.Bar.Web/Scripts/CanvasJS/**/*, Foo.Bar.Web/Scripts/JQueryUi/**/*, Foo.Bar.Web/Scripts/DataTables/**/*, Foo.Bar.Web/Content/**/*, Foo.Bar.Web/App_Start/**/*, Foo.Bar.Data/Model/**/*, Model/**/*, **/AssemblyInfo.cs, **/*Test.cs, Foo.Bar.Test.Web/**/*, Foo.Bar.JeuTest/**/*, Foo.Bar.Gestion.Web/**/*, **/*.js"
/d:sonar.tests="Foo.Bar.Test"
/d:sonar.cs.opencover.reportsPaths="D:/Program Files (x86)/Jenkins/workspace/Bar/reports/opencovertests.xml"
/d:sonar.cs.nunit.reportsPaths="D:/Program Files (x86)/Jenkins/workspace/Bar/reports/TestResult.xml"

我的“msbuild之后”命令(windows):

MKDIR "%WORKSPACE%\reports"
MKDIR "%WORKSPACE%\reports-history"

SET COV_PTH="D:\Programmes\opencover.4.6.519"
SET TOOL_PATH="D:\Programmes\NUnit-3.4.1"
SET RPT_PATH="D:\Programmes\ReportGenerator"

%COV_PTH%\OpenCover.Console.exe -target:"%TOOL_PATH%\bin\nunit3-console.exe" -targetargs:"Build\Foo.Bar.Test.dll -result:reports\TestResult.xml;format=nunit2" -filter:"+[Foo.Bar.*]*  -[Foo.Bar.Test]* -[Foo.Bar.Data]Foo.Bar.Data.Model.*" -register -output:"reports\opencovertests.xml"

%RPT_PATH%\ReportGenerator.exe "-reports:reports\opencovertests.xml" "-targetdir:reports-ReportGenerator" "-historydir:reports-history"

版本:

  • Jenkins:2.74
  • SonarQube:6.5
  • MSBuild的SonarQube扫描程序:3.0.2.656
  • SonarQube扫描仪:3.0.3.778
  • SonarC#plugin:6.4.1
  • OpenCover:4.6.519
  • nUnit:3.4.1
  • MSBuild:14

1 个答案:

答案 0 :(得分:0)

在调用OpenCover.Console.exe时,您需要使用parameter + value: -register:user而非仅-register
在同一命令行中,请确保位于最终存储报告的文件夹D:/Program Files (x86)/Jenkins/workspace/Bar/中。