Unable to get SonarQube to pick test code coverage

  1. Team City build pipeline to run .NET Visual Studio tests - was wired to use “Sonar Scanner for .NET”
  2. the build is creating coverage and shows it in Team City , the report file was also created.
  3. But SonarQube for the project still shows 0 coverage.
  4. Searched for similar issues in current forum, but could not find something similar that resolved the issue that i see in the build log = Sensor Zero Coverage Sensor

Build log attached
SonarQube_Build.log (37.9 KB)

Hi,

Welcome to the community!

The log you’ve attached shows the end step running immediately after the begin step, with no build or coverage generation between them. Is that actually what happens? Also, It looks like your coverage actually runs after analysis. The order needs to be:

  • start
  • rebuild
  • coverage
  • end

 
HTH,
Ann

Actually , i deleted a bulk of the build logs between the both - start and end. The start and end are in fact bookends to the true build and coverage.

Team city is showing coverage results and we have the results file. The file is not getting pushed to SonarQube is the issue. If you want to see the entire log, i can put that out here. From another build we just ran.
FIRE_AutoCAD_Commit_Build_and_Run_Unit_Tests_11.7.0.85.log (195.7 KB)

Hi,

In the part of your log that’s labeled for the begin step, I don’t actually see the begin step, I see stuff about PowerShell. Do you have a PS script executing the begin command? I was looking for it to double-check the sonar.cs.dotcover.reportsPaths value.

 
Ann

not really, the begin step is just using the Runner - “SonarScanner for .NET (dotnet scanner)”.

no powershell script to indicate reportpaths.

There is a unit test step right before the end - that is the Visual Studio tests - running step, it takes additional parameters, shall i set the sonar.cs.dotcover.reportsPaths path there ? if so how?

Hi Misha

In the latest verion of SonarQube we’ve improved the documentation for .NET coverage including a sample of how to setup dotcover and where to set the reportspath. It can be found here.

Let me know if you’re still having problems

Tom

Thanks Tom. I did go through the documentation and checked the meta runner we are using to include more debug information to pick up.

Issue seems to have been caused with - though coverage report was generated, there was no source code for the coverage that SonarQube was expecting.

Resolved the issue by changing the way we were building our solution - and have the source code show up in Team city code coverage. Once that was showing up - SonarQube started showing coverage. All set. Thank you so much for sending the documentation. That is definitely helpful.