Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure DevOps: How to merge two code coverage reports for different tests (.net core, angular)

We have two different types of tests in pipeline: unit(.net core) and frontend (angular/karma). Each of them can publish code coverage report via to "PublishCodeCoverageResults@1", but only one front or back. It depends on which test runs last. I think the last coverage owerwrites previous. However we need both code coverage publish.

Is there way to merge 2 coverage report and then publish them in one Code Coverage tab or add the second tab?

like image 962
Dmitry Zimin Avatar asked Sep 30 '19 10:09

Dmitry Zimin


People also ask

How do I add code coverage to azure DevOps?

As already explained in my previous article, the very first thing to do to add code coverage calculation is to install a NuGet package called Coverlet. This package must be installed in every test project in your Solution. So, running a simple dotnet add package coverlet. msbuild on your test projects is enough!

How do I publish a Testng report in Azure DevOps?

So, we can publish TESTNG test results in JUnit format instead. You could use the Publish Test Results task to publish the reports. Please select the “JUnit” Test result format and change the Test results files as **/junitreports/TEST-*. xml .

How do I open code coverage results?

Code coverage option is available under the Test menu when you run test methods using Test Explorer. The results table shows the percentage of the code executed in each assembly, class, and procedure. The source editor highlights the tested code.


1 Answers

Is there way to merge 2 coverage report and then publish them in one Code Coverage tab or add the second tab?

AFAIK, ReportGenerator can merge multiple coverage files into one, e.g. merge several Cobertura XML files into just one Cobertura XML file:

Check the document ReportGenerator for some more details.

You can do the following steps in the Azure devops:

  • Install the ReportGenerator extension: https://marketplace.visualstudio.com/items?itemName=Palmmedia.reportgenerator
  • Configure the ReportGenerator task to produce HTML and Cobertura (this is the default)
  • Configure the Publish code coverage results task and point it to the HTML files directory and the merged Cobertura file generated by ReportGenerator

Currently the Publish code coverage results task regenerates the HTML report. To avoid that, you have to create a new environment variable: disable.coverage.autogenerate: 'true'

Check this thread for some more details.

Hope this helps.

like image 197
Leo Liu-MSFT Avatar answered Sep 28 '22 22:09

Leo Liu-MSFT