Unit Test count always showing 0 in dashboard

Must-share information (formatted with Markdown):

  • I am using SonarQube
  • Trying to show code coverage % and Unit Test count in Sonarqube Portal
  • Configured Project in sonarqube, able to see Bugs, Code smells etc.
    Project implemeted in .Net 6.0 version using VS2022
  • Want to show code coverage and Unit Test count in dashboard

I ran belwo commands to dispaly code coverage and Unii Test,

  1. dotnet “C:\sonar-scanner-msbuild-\SonarScanner.MSBuild.dll” begin /k:“VCA.AW.API.NUnit.New” /d:sonar.host.url=“http://localhost:9000” /d:sonar.login=“eeb355e2638249b2c16b71c362df6e94ab356196” /d:sonar.cs.opencover.reportsPaths=“D:\VCA Projects\AppointmentWaitlistAPI_NUnit\VCA.AW.API\VCA.AW.API.UnitTest*\TestResults*\coverage.opencover.xml" /d:sonar.cs.xunit.reportsPaths="D:\VCA Projects\AppointmentWaitlistAPI_NUnit\VCA.AW.API\VCA.AW.API.UnitTest*\TestResults\TestOutput.xml”
  2. dotnet build “D:\VCA Projects\AppointmentWaitlistAPI_NUnit\VCA.AW.API\VCA.AW.API.sln” -nr:false
  3. dotnet test --no-build “D:\VCA Projects\AppointmentWaitlistAPI_NUnit\VCA.AW.API\VCA.AW.API.UnitTest” --logger:trx;LogFileName=“D:\VCA Projects\AppointmentWaitlistAPI_NUnit\VCA.AW.API\VCA.AW.API.UnitTest\TestResults\TestOutput.xml” --collect:“XPlat Code Coverage” – DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
  4. dotnet “C:\sonar-scanner-msbuild-\SonarScanner.MSBuild.dll” end /d:sonar.login=“eeb355e2638249b2c16b71c362df6e94ab356196”

By doing this i am able to see code coverage but Unit Test count shwoing 0 always.Can somebody help me to understand the issue.


You need to make sure you’re generating an execution report and passing it in to analysis with the right parameter.

:warning: Also, make sure you upgrade to SonarQube v9.9 LTS soon, not only to benefit from our Best LTS Ever™, but because soon we will systematically ask users to upgrade when they ask questions about earlier versions of SonarQube, which are now considered unsupported. :smiley: