Code coverage and Unit test success values ​​not showing in SonarQube 4.4 dashboard

Environment: Windows 7 | SonarQube 4.4 | SonarRunner 2.4 | .NET (C #) | Visual Studio Professional 2013

I am using Sonar 3.2 and SonarRunner 2.0. Coverage code and Unit test success values ​​are displayed on the Sonar dashboard.

With the same set of configurations, when I upgrade to SonarQube 4.4 and SonarRunner 2.4, the code coverage and Unit test success values ​​are not shown in the SonarQube 4.4 dashboard.

sonar project properties:

# Project identification
sonar.projectKey=LLTest_Sonar_Report
sonar.projectVersion=1.0
sonar.projectName=LLTest

# Info required for Sonar 
sonar.sources=.
sonar.language=cs
sonar.sourceEncoding=UTF-8

sonar.visualstudio.enable=true

#Code Coverage
sonar.cs.opencover.reportPaths=coverage.xml
#sonar.cs.vstest.reportsPaths=results.trx

#Core C# Settings
sonar.dotnet.visualstudio.solution.file=LLTest.sln
sonar.silverlight.4.mscorlib.location=C:/Program Files/Reference Assemblies/Microsoft/Framework/Silverlight/v4.0
sonar.dotnet.excludeGeneratedCode=true
sonar.dotnet.4.0.sdk.directory=C:/Windows/Microsoft.NET/Framework/v4.0.30319
sonar.dotnet.version=4.0 

# To prevent any issues while analyzing multiple solutions containing projects with similar keys
# Will be set by default to safe starting at version 2.2: http://jira.codehaus.org/browse/SONARDOTNT-339
#sonar.dotnet.key.generation.strategy=safe

#Gendarme
sonar.gendarme.mode=

# Gallio / Unit Tests

sonar.gallio.installDirectory=C:/Program Files/Gallio

sonar.gallio.coverage.tool=OpenCover
sonar.opencover.installDirectory=C:/Program Files/OpenCover/

#sonar.opencover.mode=reusereport
#sonar.cs.vstest.reportsPaths=TestResult.trx

sonar.dotnet.visualstudio.testProjectPattern=*.Tests;*.UnitTests
sonar.dotnet.test.assemblies=C:/Users/kprasad/Documents/Visual Studio 2013/Projects/LLTest/LLTest.Tests/bin/Debug/LLTest.Tests.dll

sonar.gallio.mode=reusereport
sonar.gallio.reports.path=gallio-report.xml
sonar.gallio.coverage.reports.path=coverage-report.xml

sonar.stylecop.projectFilePath=C:/Users/kprasad/Documents/Visual Studio 2013/Projects/LLTest/LLTest/LLTest.csproj
sonar.stylecop.installDirectory=C:/Program Files/StyleCop 4.7
sonar.resharper.projectName=LLTest
sonar.resharper.solutionFile=LLTest.sln
sonar.cs.fxcop.fxCopCmdPath=C:/Program Files/Microsoft Visual Studio 12.0/Team Tools/Static Analysis Tools/FxCop/FxCopCmd.exe
sonar.cs.fxcop.assembly=C:/Users/kprasad/Documents/Visual Studio 2013/Projects/LLTest/LLTest.Tests/bin/Debug/LLTest.Tests.dll

# FXCop 
#sonar.fxcop.mode=reusereport 

# StyleCop 
#sonar.stylecop.mode=reusereport

# NDeps
#sonar.ndeps.mode=reusereport

      

Understand that we need to get the Coverage XML file generated through the batch file and using this we can see the coverage results in the SonarQube dashboard.

I cannot get the Coverage XML file generated via a batch file that contains the following:

cd C:\Users\kprasad\Documents\Visual Studio 2013\Projects\LNTest"C:\Program Files\Microsoft Visual Studio 12.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe" collect /output:VisualStudio1.coverage "C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "C:\Users\kprasad\Documents\Visual Studio 2013\Projects\LNTest\LNTest.Tests\bin\Debug\LNTest.Tests.dll""C:\Program Files\Microsoft Visual Studio 12.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe" analyze /output:VisualStudio.coveragexml VisualStudio.coverage pause

      

Please help with this. Please advise if further details are required, thanks.

Regards, KP

+3


source to share


2 answers


We have these command lines to get the open cover results file:



set Configuration=debug
set MSTest=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest.exe
call "%~dp0packages\OpenCover.4.5.2506\OpenCover.Console.exe" -register:user -target:"%MSTest%" -targetargs:"/resultsfile:Project.Name.Tests.trx /noisolation /testcontainer:%~dp0Project.Name.Tests\bin\%Configuration%\Project.Name.Tests.dll" -filter:+[Project.Name]* -output:"%~dp0results.xml"

      

+1


source


Once you get the coverage result, you should be able to generate the XML required by the sonar using the CodeCoverage tool, instead of using the collection modifier, use parsing:

"C:\Program Files\Microsoft Visual Studio 12.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe" analyze /output:VisualStudio1.coverageXml VisualStudio1.coverage

      



but the trick is using it in a different step and not on the same line of your script

0


source







All Articles