This Question is Not Answered

1 "correct" answer available (4 pts) 1 "helpful" answer available (2 pts)
6 Replies Last post: Jul 6, 2014 7:36 PM by Eyal Azran  
Eyal Azran Newbie 7 posts since
Apr 4, 2013
Currently Being Moderated

Jun 15, 2014 3:47 PM

How to make dotCover play nice with SonarQube?

Hi All,

 

I am using TeamCity 8.0.4 and SonarQube 4.3

 

I am trying to get test coverage results in SonarQube for a C# project.

 

TeamCity runs dotCover analysis as part of MSTest build step.

 

The code coverage summary appears in the TeamCity build overview, but I'm not sure how to transmit this data to Sonar

 

The Sonar C# plugin accept the parameter: sonar.cs.dotcover.reportsPaths

(see here: http://docs.codehaus.org/display/SONAR/C%23+Plugin under the code coverage section)

 

but I can see in the logs that the dotCover report is saved to a temporary location (D:\TeamCity\BuildAgent1\temp\buildTmp):

 

 

[JetBrains dotCover] Coverage session finished [15/06/2014 12:22:14]
[JetBrains dotCover] Coverage results post-processing started [15/06/2014 12:22:14]
[JetBrains dotCover] Coverage results post-processing finished [15/06/2014 12:22:15]
##teamcity[importData id='mstest' file='D:\TeamCity\BuildAgent1\temp\buildTmp\tmp623A.tmp.teamcity.trx']
##teamcity[importData type='dotNetCoverage' tool='dotcover' file='D:\TeamCity\BuildAgent1\temp\buildTmp\coverage_dotcover3838966080337633281.data']
Importing data from 'D:\TeamCity\BuildAgent1\temp\buildTmp\tmp623A.tmp.teamcity.trx' (21.94 KB) with 'mstest' processor
MSTest report watcher
[MSTest report watcher] Watching paths:
[MSTest report watcher] D:\TeamCity\BuildAgent1\temp\buildTmp\tmp623A.tmp.teamcity.trx

 

 

I think this is the reason SonarQube shows no results available for unit test coverage.

In SonarQube, other data is shown, just the unit tests coverage results are missing.

Sonar01.jpg

Does anyone know if I can pass a parameter to dotCover so it saves the coverage report somewhere Sonar can find instead of a temporary location?

 

Thanks,

Eyal

Alina Mishina JetBrains 248 posts since
May 22, 2014
Currently Being Moderated
Jun 18, 2014 6:13 PM in response to: Eyal Azran
Re: How to make dotCover play nice with SonarQube?

Hi,

 

Unfortunately now it is impossible to configure it as you want. We have an issue http://youtrack.jetbrains.com/issue/TW-25204 to add a new parameter where will be stored a path to the coverage report in temp directory, please watch and vote.

Also there is a related issue http://youtrack.jetbrains.com/issue/TW-36940 to add ability to publish coverage data as artifacts.

Alina Mishina JetBrains 248 posts since
May 22, 2014
Currently Being Moderated
Jun 19, 2014 1:18 PM in response to: Eyal Azran
Re: How to make dotCover play nice with SonarQube?

All artifacts are saved to <TeamCity data directory>/system/artifacts folder, coverage artifacts are hidden and are placed under the .teamcity directory in the root of the build artifacts. So it is possible to get them from server in another build configuration (using artifact dependency). But as far as SonarQube also uses sources and binary files it should be executed at the same build configuration as dotCover (to avoid data inconsistency). Now we have no workaround for this issue.

Steve Chapman Newbie 1 posts since
Jul 1, 2014
Currently Being Moderated
Jul 1, 2014 5:32 AM in response to: Eyal Azran
Re: How to make dotCover play nice with SonarQube?

You may be able to achieve what you want by adding a simple copy step after your tests / coverage run (I'm currently trying to solve exactly the same issue - will report back with my findings)

 

  1. Add a Command Line build step after your Unit Tests / Coverage have completed - copy "%system.teamcity.build.tempDir%\coverage_ncover*.data" "%system.teamcity.build.checkoutDir%\coverage.xml"
  2. Run your sonar-runner with -Dsonar.cs.ncover3.reportsPaths=coverage.xml (or specified in sonar-project.properties)

 

Can't guarantee it works at this stage, but worth a shot.

More Like This

  • Retrieving data ...