Difference between Code coverage report of VS test and SonarQube

Hi all,

We have a WebAPI project written in C# and using Visual Studio 2019. We have also written unit test cases using nunit framework for the WebAPI project. We are using Azure DevOps pipeline to build and deploy the solution. With the Azure DevOps pipeline we have integrated the SonarQube for reporting the code quality and code coverage. We are using “SonarQubePrepare@4” and “VSTest@2” tasks in DevOps pipeline with below properties.

task: SonarQubePrepare@4
      displayName: Test      
        SonarQube: 'xxxx'
        scannerMode: 'MSBuild'
        projectKey: 'xxxxx'
        extraProperties: |                
               sonar.cs.vscoveragexml.reportsPaths =  

task: VSTest@2
      displayName: VSTest
      continueOnError: true
        testSelector: 'testAssemblies'
        testAssemblyVer2: |
        searchFolder: '$(System.DefaultWorkingDirectory)'
        resultsFolder: '$(System.DefaultWorkingDirectory)\Test'        
        codeCoverageEnabled: true

We are seeing different code coverage report in VS Test report and SonarQube report.

Code Coverage in VS test

Code Coverage in SonarQube

Please let me know how can I show the VS Test report in the SonarQube report.

Alok Kumar

Hi Alok,

Welcome to the community!

This blog post may help.