SonarQube is Showing CodeCoverage but not showing test count on Dashboard - .Net Core Web API

SonarQube Version: 9.3.0.51899

I had written test cases for .net core web API and then integrated that with sonar, as sonar is showing code coverage but not showing test count, can anyone help me with it.

I used following commands to achieve code coverage

dotnet tool install --global dotnet-sonarscanner --version 5.2.0
dotnet tool update dotnet-reportgenerator-globaltool -g --version 4.8.7

dotnet sonarscanner begin /k:"MyProject" /d:sonar.host.url="http://localhost:9000"  /d:sonar.login="Token" /d:sonar.coverageReportPaths=".\sonarqubecoverage\SonarQube.xml"

dotnet build

dotnet test --no-build --collect:"XPlat Code Coverage"

reportgenerator "-reports:*\TestResults\*\coverage.cobertura.xml" "-targetdir:sonarqubecoverage" "-reporttypes:SonarQube"

dotnet sonarscanner end /d:sonar.login="Token"

image

Your help would be appriciated.

Thanks.

Hey there.

This requires passing Test Execution Reports details in the right format, which is different than Test Coverage Reports (and uses different analysis parameters).

Since you tagged this post with #nunit… I’d start looking at sonar.cs.nunit.reportsPaths :smiley:

1 Like

@Colin Good to hear from you.

Can you kindly guide me on how to make it of use? I find sonar.cs.nunit.reportsPaths as a solution at many sites but I don’t get how to use it or where to use it.
Your response would be appreciated.
Thanks.

You are probably interested in this documentation which describes different output formats available for test execution results for dotnet test.

From there, it’s a matter of passing the right report to the right analysis parameter (the same way you’ve passed sonar.coverageReportPaths)

@Colin I do tried that but that doesn’t work for me. instead of showing count now it isn’t showing percentage also.