OpenCover generates an empty report

I am using SonarQube Version 8.9.6 (build 50800). Using OpenCover to determine code coverage for a c#10 project (.Net 6)
I want to get the code coverage report. Using dotnet CLI to run the tests. The tests are running and the file is being created but the coverage file is empty.

I am using this command:
-oldstyle -log:warn -returntargetcode -register:Path64 -output:coverage.xml -mergebyhash “-target:dotnet.exe” “-targetargs:test --no-build --no-restore --configuration Release – NUnit.TestOutputXml=${bamboo.build.working.directory}\Result”

Does anyone know what is wrong here?

Hey there.

Without full logs from the command you’re running, it will be hard to diagnose anything.

A couple of pointers:

  • At the end of the day, SonarQube isn’t involved in generating the report, only in reading the report. If it’s empty… this might not be the right forum to ask for help.
  • OpenCover/opencover is now archived, and you might find it useful to use a tool like AltCover instead
  • We have documentation in later versions of SonarQube specific to .NET Test Coverage that might help you explore different options

In the meantime, I’ll check with the relevant team if we should be changing references from openCover to altCover.

Hope this helps!

1 Like

Thanks for the quick response. I will have a look.

Can you tell if it is possible to use multiple coverage reports with the following command:

/d:sonar.cs.opencover.reportsPaths=.\firstFolder\coverage.xml, .\secondFolder\coverage.xml

Yes, you can (ideally without spaces inside), and you also can use wildcards - see examples:

Regarding altCover, OpenCover or coverlet - these tools support the opencover reports, and you can use whichever of these tools to generate code coverage reports in the opencover format.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.