How to import code coverage?

I have download sonarqube 8.3 community edition.
I am using open cover 4.7.922.
I am using windows 10.
I’m using java 11.0.7
I have msbuild and java in set in the environment variables.

I have generated several xml files in this directory

  • coverage.xml
  • coverage1.xml
  • coverage2.xml

Steps i have performed
Step 1 cd to the solution directory.

Step 2 run the command below.
SonarScanner.MSBuild.exe begin /k:“Azure” /d:sonar.cs.opencover.reportsPaths=“C:\Users\rafaelg\Documents\CodeCoverageScript” /“http://localhost:9000” /d:sonar.login=“03470e1ac912746065a952d2ec37ace205e5c7ea”

Step 3 run the command below.
MsBuild.exe /t:Rebuild

Step 4 run the command below.
SonarScanner.MSBuild.exe end /d:sonar.login=“03470e1ac912746065a952d2ec37ace205e5c7ea”

I get a report in the dashboard and the command line reports it has been successful but i don’t have any code coverage.

What am i missing?

Hi Rafael,

Welcome to the SonarSource Community!

First, I’d check that your OpenCover reports are being output to C:\Users\rafaelg\Documents\CodeCoverageScript, where the scanner is expecting them.

If they are, can you run your scan using the debug (/d:sonar.versobe=true) option? If the issue is not apparent, can you zip and post the output from the scanner?



I combined all the tests to a single file, and the code coverage gets imported now, although unit tests don’t appear in the analysis.

Hi Rafael,

Glad to hear you have this working.

While the count of unit tests will be imported, you cannot drill down to the tests themselves.