Coverage.opencover.xml file report generated in ADO pipeline, but CC % not displayed on Sonar cloud

I am able to generate coverage.opencover.xml with coverage breakup on C# source code. Also, Sonar logs on ADO pipeline showing coverage report got imported.
Coverage Report Statistics: 13 files, 13 main files, 13 main files with coverage, 0 test files, 0 project excluded files, 0 other language files.

Code coverage percentage not displayed on Sonar cloud dashboard. Please suggest a solution on this issue.

Converting Cobertura.xml file to opencover file with below command to publish on Sonar cloud.

dotnet test --configuration Debug --no-build --logger “trx;LogFileName=$(Build.SourcesDirectory)\TestResults\test_results.trx” --collect:“XPlat Code Coverage” – DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover

Hey there.

I think you’re facing a bug that was reported last month:

It only affects PRs with no lines of code that can be covered by tests (0 new lines)

A fix is scheduled for an upcoming hardening sprint.

Can you confirm if these issues are happening on PRs with 0 new lines?

1 Like

Yes on feature branch with no code changes as such. But, coverage.xml file contains the code coverage details.

Then I think you’re just facing this UI bug (:crossed_fingers: it gets fixed soon). As long as you have coverage details on your main branch, you know the import of coverage is working well.

We are initiating Code coverage from feature branch. In main branch, still CC not enabled. Is it still UI bug???

If you’re facing an issue on the main branch, then it’s probably a different issue. The first place to look is what the logs say about the import of code coverage.

Able to publish code coverage percentage on Sonar cloud from main branch. The issue is when we try from feature branch. Please let us know once the issue is fixed. Thank you.