Code Coverage is not reflecting on SonarQube

Hi team,

I am performing SCA and code coverage of .NET core application from Azure Pipeline to SonarQube. Where I am able to generate the Open Cover after executing test cases and able to see the Code Coverage on Azure DevOps. But not able to See the Code Coverage percentage on SonarQube. Where I am able to see the " - " instead of percentage.

Using SonarQube 9.9 Community version.

Hi,

It sounds like you’re not passing a coverage report into analysis. The docs should get you started.

 
HTH,
Ann

Hi Ann,

I have tried with Coverlet to generate the Code Coverage and added all the properties mentioned over there.

I am performing this for multiple Dot Net Core Applications but facing the issue for one application where I have followed the similar process for all the applications.

NOTE: I am able generate the report with name Opencover.xml having the Coverage data and able to see the result of the file on Azure DevOps Code Coverage tab but not able to see the result to the SonarQube. Where I am able to " - " instead of Numbers.

Let me know if you require any other data.

Thankyou.

Hi,

Please share your analysis configuration and a debug analysis log.

Share the Scanner for .NET verbose logs

  • Add /d:"sonar.verbose=true" to the…
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
    • “SonarQubePrepare” or “SonarCloudPrepare” task’s extraProperties argument if you are using Azure DevOps
      • For example:
        - task: SonarCloudPrepare@3
            inputs:
              SonarCloud: 'sonarcloud'
              organization: 'foo'
              scannerMode: 'dotnet'
              projectKey: 'foo_sonar-scanning-someconsoleapp'
              projectName: 'sonar-scanning-someconsoleapp'
              extraProperties: |
                sonar.verbose=true
        
  • The important logs are in the END step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)

Share the msbuild detailed logs

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

 
Ann