0
votes

I'm using SonarQube and Jenkins. In Jenkins, I check the unit tests with nUnit and the coverage with opencover. The opencover's report is displayed in Sonar but the nunit's report is not.

Coverage is displayed

Unit tests are not displayed

I followed the instructions at : Analysing with SonarQube Scanner for Jenkins and at : Unit Test Execution Results Import

My "Begin Analysis and SonarQube for MSBuild" 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"

My "after msbuild"'s command (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"

Versions :

  • Jenkins : 2.74
  • SonarQube : 6.5
  • SonarQube scanner for MSBuild :3.0.2.656
  • SonarQube Scanner : 3.0.3.778
  • SonarC# plugin : 6.4.1
  • OpenCover : 4.6.519
  • nUnit : 3.4.1
  • MSBuild : 14
1
What's the version of your Sonar C# plugin? The support for NUnit came with the latest version - 6.4. - Val
@Valeri-SonarSourceTeam 6.4.1 - jBravo
@Valeri-SonarSourceTeam Do you have any idea of what going on? Do you want more information? - jBravo
@Valeri-SonarSourceTeam One year later, the problem is still there... - jBravo

1 Answers

0
votes

When calling OpenCover.Console.exe you need to use parameter+value: -register:user instead of -register only.
In same command line, be sure to be located in folder D:/Program Files (x86)/Jenkins/workspace/Bar/, where the report is stored finally.