This Question is Possibly Answered

1 "correct" answer available (4 pts) 1 "helpful" answer available (2 pts)
8 Replies Last post: Aug 11, 2014 8:04 PM by Alina Mishina  
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 439 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 439 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.

David Razzetti Newbie 17 posts since
Sep 5, 2012
Currently Being Moderated
Aug 6, 2014 8:38 PM in response to: Eyal Azran
Re: How to make dotCover play nice with SonarQube?

The C# Sonar plugin associated with Sonar 4.3 and DotCover 2.7 do work together...

 

The Java error that you see is because you used the wrong DotCover command to generate the coverage report.

The Sonar plugin requires the output from an Analyse command or a Report command.  You must specify that you want an HTML report.

When I run an Analyse command in DotCover 2.7 asking for an HTML report, the file produced starts like this:

 

<!DOCTYPE html>
<html class="main">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>MyTests.dll.Coverage</title>

 

...and the C# Sonar plugin accepts it.

 

I do see another issue with coverage from DotCover, however.  I am seeing DotCover 2.7 producing incomplete coverage reports which I then import into Sonar.

I have started a separate thread on this today (6th August 2014).

Alina Mishina JetBrains 439 posts since
May 22, 2014
Currently Being Moderated
Aug 11, 2014 8:04 PM in response to: David Razzetti
Re: How to make dotCover play nice with SonarQube?

Hi,

 

A SonarQube plugin has been released. Please try it, any feedback is highly appreciated.

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 ...