Search code examples
unit-testingcode-coveragecoberturagcovr

Is there anyway to merge cobertura coverage xml reports together?


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!


Solution

  • I wrote python script which can merge cobertura reports together. It only merges line "hits" and is able to filter specific packages while merging.

    Conditional(branch-rate) coverage and line coverage (line-rate) percentage values are not merged yet. Jenkins plugin recalculates these values so in this context it doesn't have to be implemented (but maybe it will).

    Also conditional coverage can't seem to be put together easily, so it doesn't work when reports cooperate on final value (meaning one file has condition-coverage 50% (2/4) and other also condition-coverage 50% (2/4) other two branches. Result is set to be higher of these two numbers so it will be still 50% (2/4)