Is there anyway to merge cobertura coverage xml reports together?
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
.
It seems you're using gcovr. Since version 4.2, gcovr can merge its JSON reports with the -a
option. So you could do:
# run test1
./test1
gcovr ... --xml coverage-test1.xml --json coverage-test1.json
find . -type f -name '*.gcda' -exec rm {} +
# run test2
./test2
gcovr ... --xml coverage-test2.xml --json coverage-test2.json
find . -type f -name '*.gcda' -exec rm {} +
# combine JSON reports
gcovr -a coverage-test1.json -a coverage-test2.json --xml coverage-combined.xml
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