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?
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!
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 .
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With