SonarQube don't show results of coverage test

Hi!
We use:

  • SonarQube Enterprise Edition Version 9.3 (build 51899)
  • GitHub Action task: sonarsource/sonarqube-scan-action@master with SonarScanner 4.6.2.2472
  • dotNET 6.0 project

In CI-pipeline we run coverage-tests with the command “dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover”.
After that we see in the logs information about our coverage-tests:
image
Also we see that SonarQube imports this information:

INFO: Parsing the OpenCover report /github/workspace/./src/External/OdataToEntity.Test.CosmosDb/coverage.opencover.xml
INFO: Adding this code coverage report to the cache for later reuse: /github/workspace/./src/External/OdataToEntity.Test.CosmosDb/coverage.opencover.xml

But on the portal I see another information:
image

Coverage = 0 lines
Why does this happen?
Thanks in advance.

Hey there.

Can any of the 65 new lines you introduced actually be covered by tests? Do you see coverage reported in the Overall Code section of your branch?

Hi Colin,
Thank you for your answer.

I don’t have the Overal Code section in my current branch.
image
Earlier in the master branch, we did not use coverage tests. But now we need to do it. And I am testing it in my branch.

Hi!
Thank you for your help.
I solved my problem.
For this task – SonarQube + GitHub Actions + dotNet 6.0 – we need to do these steps in our workflow:

dotnet restore
dotnet tool install --global dotnet-sonarscanner
dotnet sonarscanner begin /k:*** /d:sonar.login=*** /d:sonar.host.url=*** /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml"
dotnet build <some your parameters>
dotnet test <some your parameters> /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
dotnet sonarscanner end /d:sonar.login=***

As a result we have:
image

1 Like

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