3

I have an entity framework .net core application as a backend and .net core react app for the front-end.

I am trying to setup azure pipelines for this project.

While I am setting the pipeline for .net core react app I am running the library tests (code coverage is generated) also as it is the referenced project to my UI project.

The Issue here is when I run the JEST tests for the .net core react app, it is also generating test coverage but in the summary of build pipeline test coverage tab is not showing the code coverage when I enable the code coverage of library.

I am able to see both coverages in the artifacts published.

How can I see both coverages in my build summary?

Dulanjaya Tennekoon
  • 2,408
  • 1
  • 18
  • 31
  • JEST code coverage is not supported by Azure Pipelines Build yet. – Eriawan Kusumawardhono May 21 '19 at 13:51
  • 1
    Sorry @EriawanKusumawardhono Jest code coverage works in azure build. Not displaying in the Test coverage Tab when I have another code coverage by VSTEST but it is in the artifacts but links to navigate to the files wont work. :( – Prasanna kumar May 23 '19 at 11:16
  • I have the same problem. Having a 'PublishTestResults@2" task for my .net core tests and "PublishCodeCoverageResults@1" for Cobertura is only displaying the .NET Core results in the "Code coverage" taband the Cobertura results are only visible in the build artifacts. – Alex Marinov Mar 04 '20 at 10:41

2 Answers2

3

To combine multiple coverage reports into one, you can use the reportgenerator task. The reportgenerator takes multiple coverage files and combines them into one single coverage file. This new coverage file can then be published using the

Example:

steps:
- task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
  displayName: ReportGenerator
  inputs:
    reports: '*\TestResults\*\coverage.cobertura.xml'
- task: PublishCodeCoverageResults@1
  displayName: 'Publish code coverage'
  inputs:
    codeCoverageTool: Cobertura
    summaryFileLocation: 'coveragereport\Cobertura.xml'
    failIfCoverageEmpty: true

Here's an article that describes this in greater detail: https://www.jamescroft.co.uk/combining-multiple-code-coverage-results-in-azure-devops/

eddex
  • 1,622
  • 1
  • 15
  • 37
1

how to include multiple code coverage's in the pipeline

It seems you are using the Publish Code Coverage Results task, it's unlike to use Publish test results task. But you could not be able to publish multiple coverage test results in a single task.

When you have two coverage.xml files, Azure Devops Build definition will only use one of them.

To resolve this issue, try to add another Publish Code Coverage Results task in build pipeline for each package.

If it not helps you, please share your build definition in your question.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • Thanks for the response. In my pipeline I already have a build step to publish test(jest) coverage, and VS Test by default creating a test coverage (checkbox selected) and published in to the artifacts. If I stop the code coverage of VS Test the jest coverage is working fine. – Prasanna kumar May 23 '19 at 11:10
  • 1
    I don't think you can publish more than one set of code coverage results, per [this Q&A](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-code-coverage-results?view=azure-devops#q--a) on the Publish Code Coverage Results task documentation. Specifically, "If you use multiple publish code coverage tasks in the pipeline, the summary and report is shown for the last task. Any previously uploaded data is ignored." – Gregg L Apr 21 '20 at 14:03