Kali Prasad
Kali Prasad

Reputation: 33

Code coverage and Unit test success values are not displaying in SonarQube 4.4 dashboard

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

I have been using Sonar 3.2 & SonarRunner 2.0. Code coverage and Unit test success values are being displayed in Sonar dashboard.

With the same set of configurations, when I upgrade to SonarQube 4.4 & SonarRunner 2.4, Code coverage and Unit test success values are not displaying in 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

Got to know that we need to get Coverage XML file generated through a batch file and using that we can see coverage results in SonarQube Dashboard.

I'm unable to get the Coverage XML file generated through the batch file which 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 in this. Let know if any additional details are required, thanks.

Regards, KP

Upvotes: 3

Views: 3669

Answers (2)

XtianGIS
XtianGIS

Reputation: 1006

After you get the coverage result, you will be able to generaqte the XML file required by sonar using the CodeCoverage tool, instead of using the collect modifier, use the analyze:

“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 use it in another step, not in the same line of your script

Upvotes: 0

Boltyk
Boltyk

Reputation: 317

We have these batch file lines to get 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"

Upvotes: 1

Related Questions