azure-devopscontinuous-integrationazure-pipelinescode-coveragereportgenerator

Single code coverage report for multiple test projects within one azure build pipeline


Tried creating a single code coverage report for multiple test projects within a single build pipeline - Multiple stages within a single build.

- task: DotNetCoreCLI@2
      displayName: Run Test
      inputs:
        command: 'test'
        projects: |
          $(FunctionProjectBase)/$(FunctionShortName1)/*.csproj
        arguments: --configuration $(BuildConfiguration) --collect "XPlat Code coverage"

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

- task: DotNetCoreCLI@2
      displayName: Run Test
      inputs:
        command: 'test'
        projects: |
          $(FunctionProjectBase)/$(FunctionShortName2)/*.csproj
        arguments: --configuration $(BuildConfiguration) --collect "XPlat Code coverage"

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

But this is not generating code coverage report on "Code coverage tab" Azure DevOps. It only generates a downloadable file.


Solution

  • But this is not generating code coverage report on "Code coverage tab" Azure DevOps. It only generates a downloadable file.

    This is a known issue on Azure devops. Now, we could only download the report, and could open it with Visual Studio.

    Azure devops only support the download link for .coverage files currently. The white page you see is a UI glitch. This scenario is only supposed to render a download link to the coverage file.

    Besides, this issue has been submitted in this earlier suggestion ticket linked here:

    support vstest .coverage "code coverage" build results tab

    This feature request is On Roadmap, I believe it will be released soon, you can vote and follow this thread to know its latest feedback.

    Hope this helps.