SonarQube not showing coverage all test layer

I create pipeline SonarQube in Azure DevOps
But it always shows me the test results of one layer If I add “projects:‘Application.Test/Application.Test.csproj’” show only coverage layer Applicaion But I use “‘**Test/**Test.csproj’” show only coverage layer Web

If I add “projects:‘Application.Test/Application.Test.csproj’” show only coverage layer Applicaion But I use “‘**Test/**Test.csproj’” show only coverage layer Web

  - task: SonarQubePrepare@4
     inputs:
       SonarQube: 'SonaQube'
       scannerMode: MSBuild
       projectKey: 'mykey'
       projectName: 'projectname'
       projectVersion: '$(Build.BuildNumber)'
       extraProperties: |
         sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml
         sonar.cs.xunit.reportsPaths=**/TestResults.xml
         sonar.exclusions=Persistence/Configurations/**, Persistence/**, Migrations/**, Entities/**/**, Program.cs, ConfigureServices.cs

   - task: DotNetCoreCLI@2
     displayName: Restore
     inputs:
      command: restore
      projects: '**/*.csproj'
      feedsToUse: config
      nugetConfigPath: nuget.Config

   - task: DotNetCoreCLI@2
     displayName: Build
     inputs:
       command: build
       projects: '$(lowerProjectName).csproj'
       arguments: '--configuration $(BuildConfiguration)'

   - task: DotNetCoreCLI@2
     displayName: Build Test Project
     inputs:
       command: build
       projects: '**Test/**Test.csproj'
       arguments: '--configuration $(BuildConfiguration)'

   - task: DotNetCoreCLI@2
     displayName: Test
     inputs:
       command: test
       projects: '**Test/**Test.csproj'
       publishTestResults: false
       arguments: '--configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutput=$(Build.SourcesDirectory)\TestResults\ /p:CoverletOutputFormat="\"cobertura,opencover\"" -l:xunit --no-build'

   - powershell : |
       dotnet new tool-manifest --force
       dotnet tool install dotnet-reportgenerator-globaltool
     displayName: Install Report Generator

   - task: DotNetCoreCLI@2
     displayName: Report Generator
     inputs:
       command: custom
       projects: '**Test/**Test.csproj'
       custom: reportgenerator
       arguments: '"-reports:$(Build.SourcesDirectory)\TestResults\coverage.cobertura.xml" "-targetdir:$(Build.SourcesDirectory)\TestResults\Reports" -tag:$(Build.BuildNumber) -reportTypes:htmlInline'

   - task: SonarQubeAnalyze@4
     displayName: 'Run Code Analysis'

   - task: PublishTestResults@2
     displayName: Publish Test Results
     inputs:
       testResultsFormat: XUnit
       testResultsFiles: '**/TestResults.xml'

   - task: PublishCodeCoverageResults@1
     displayName: 'Publish code coverage'
     inputs:
       codeCoverageTool: Cobertura
       summaryFileLocation: '**/coverage.cobertura.xml'
       reportDirectory: '$(Build.SourcesDirectory)\TestResults\Reports'```

Hi,

Welcome to the community!

The first question here is whether test reports are being generated for all layers of your project. Once you’ve verified that, we can go further.

 
Ann

Hi Anna

Yes. There are reports of all layers in the coverage.cobertura.xml file. Also, the Testresult.xml file is generated for each layer separately. But there is only Web layer reporting in SonarQube.

Hi,

I see that you’re specifying this:

According to the docs:

The remarks for properties that support wildcards will mention this fact.

sonar.cs.opencover.reportsPaths

Path to the OpenCover or Coverlet coverage report.

The remarks don’t mention supporting wildcards, so I suppose the property doesn’t support them. Have you tried using a full list of all the report paths?

 
Ann

I added this code to yaml

sonar.cs.vscoveragexml.reportsPaths=**/coverage.xml

but not generate file coverage.cml

Hi,

Are you actually using Visual Studio code coverage? Did you add --collect "Code Coverage" to your test command?

 
Ann

Hi

yes

- task: DotNetCoreCLI@2
     displayName: Report Generator
     inputs:
       command: custom
       projects: '**Test/**Test.csproj'
       custom: reportgenerator
       arguments: '"-reports:$(Build.SourcesDirectory)\TestResults\coverage.cobertura.xml" "-targetdir:$(Build.SourcesDirectory)\TestResults\Reports" -tag:$(Build.BuildNumber) -reportTypes:htmlInline

when use this code create “coverage.cobertura.xml” file and save this root “$(Build.SourcesDirectory)\TestResults\Reports”

Hi,

You need to match the parameter you use up with the coverage collection method you use.

The docs should help.

 
Ann

Can you tell me exactly which part is the problem?

Hi,

Please give the docs a thorough read and come back to me if you have specific questions about them.

 
Ann