Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anyway to merge cobertura coverage xml reports together?

Tags:

I have c++/c application with a lots of unit tests. I would like to get overall coverage and also individual coverage of each test with condition that each test can be run only once. Format of coverage must be xml (cobertura xml) for jenkins cobertura plugin to process.

So far I generate gcno files upon compilation and gcda files when source is used. Then call gcovr to get xml file.

I would like to create coverage of each unit test (thus creating coverage xml for every unit test) and then merge these xml files into one xml file.

Thanks!

like image 450
jan-hybs Avatar asked Oct 20 '14 15:10

jan-hybs


2 Answers

The last release of ReportGenerator can merge cobertura files.

You can install it from nuget

usage:

reportgenerator "-reports:target\*\*.xml" "-targetdir:C:\report" -reporttypes:Cobertura 

A file Corbertura.xml is generated in the targetdir directory

You can use the dotnet core version to use it on linux or mac

like image 148
agua from mars Avatar answered Oct 09 '22 14:10

agua from mars


The simplest utility I've found for merging Cobertura files is cobertura-merge via NPM.

Usage:

npm install cobertura-merge cobertura -merge -o output.xml package1=input1.xml package2=input2.xml 

Or it can be used directly without installing through npx:

npx cobertura-merge -o output.xml package1=input1.xml package2=input2.xml 

Examples sourced from the GitHub README for cobertura-merge.

like image 44
Ryan Maloney Avatar answered Oct 09 '22 14:10

Ryan Maloney