Search code examples
sonarqubeteamcityresharperjetbrains-ideopencover

Merge InspectCode (Resharper) and OpenCover code coverage report into Sonar Qube Build


We are using InspectCode- Resharper plugin for generating C# code analysis report and Opencover for Code coverage report (unit test cases).

These are the two commands runs one after an another in the Teamcity. When we generate the Resharper analysis report and push to the sonar qube, we loose the code coverage report.

The question is how to merge both commands into either one script or merge the output of two commands.

These are the commands that we execute.

OpenCover command:

F:\BuildSystem\Dependencies\Sonar\OpenCover\4.5.3522\OpenCover.Console.exe -register:user -target:F:\BuildSystem\Dependencies\NUnit\nunit-console-x86.exe -targetargs:"F:\Builds\Sonar\Helix_Sonar_EsdPaymentsBpay\UnitTests\bin\Debug\DummyProject.UnitTests.dll /noshadow" -excludebyattribute:"*.ExcludeFromCodeCoverage*|*.GeneratedCode*" -filter:"+[DummyProject*]* +[App.*]* -[*Tests*]*" -hideskipped:All -mergebyhash -output:coverage-report.xml

InspectCode Comamnd

D:\sonar\MSBuild.SonarQube.Runner-1.0\MSBuild.SonarQube.Runner.exe begin /k:"dummy_project" /n:"dummy_project" /v:"sonarqube_project_version" /d:sonar.resharper.cs.reportPath="c:\resharper.xml" /d:sonar.resharper.solutionFile="dummyproject.sln"

"C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild" "D:\CommSee2010\Neon\wwwroot\Apps\dummyproject\dev\dummyproject.sln"

"d:\sonar\jetbrains-commandline-tools\inspectcode.exe" /output="c:\resharper.xml" "D:\CommSee2010\Neon\wwwroot\Apps\dummyproject\dev\dummyproject.sln"

 D:\sonar\MSBuild.SonarQube.Runner-1.0\MSBuild.SonarQube.Runner.exe end

FINAL SOLUTION:

"D:\sonar\MSBuild.SonarQube.Runner-2.0\MSBuild.SonarQube.Runner.exe" begin /k:"OFI.CS" /n:"OFI.CS" /v:"1" /d:sonar.cs.opencover.reportsPaths="D:\sonar\output\ofi.Report.opencover.xml" /d:sonar.cs.nunit.reportsPaths="D:\sonar\output\TestResult.xml" /d:sonar.resharper.cs.reportPath="D:\sonar\output\ofi.Report.xml" /d:sonar.resharper.solutionFile="D:\hx\wwwroot\apps\test\dev\test.sln" 

"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" "D:\hx\wwwroot\apps\test\dev\test.sln"

"C:\Program Files (x86)\OpenCover\OpenCover.Console.exe" -register:user -target:"C:\Program Files (x86)\NUnit 2.6.4\bin\nunit-console-x86.exe" -targetargs:"D:\hx\wwwroot\apps\test\dev\UnitTests\bin\Debug\UnitTests.dll /noshadow /xml:D:\sonar\output\TestResult.xml" -filter:"" -mergebyhash -output:"d:\sonar\output\ofi.Report.opencover.xml"

"D:\sonar\resharper\inspectcode.exe" /output="D:\sonar\output\ofi.Report.xml" /profile="D:\hx\wwwroot\apps\test\dev\test.sln.DotSettings" "D:\hx\wwwroot\apps\test\dev\test.sln"

"D:\sonar\MSBuild.SonarQube.Runner-2.0\MSBuild.SonarQube.Runner.exe" end

Solution

  • You need to upload the OpenCover output file to sonar e.g.

    /d:sonar.cs.opencover.reportsPaths="coverage-report.xml"