Combine cobertura code coverage reports of three separate projects
Asked Answered
S

2

5

I have three projects which are stored in three separate repositories. Each of them is a individual mvn project. I wonder is there a way to aggregate three reports in one?

I took a look at the cobertura aggregate function. But seems like it can only handle sub-modules of a project.

Anybody has any suggestion?

Silky answered 5/11, 2013 at 15:26 Comment(1)
In my case gcovr.com/en/stable/guide/merging.html (i.e. generating to json files then merging using the --add-tracefile option) did the trick.Macready
M
1

The Maven plugin goal cobertura:cobertura supports an aggregate parameter that would work for all the projects in the reactor I suppose.

But you seem to suggest the projects might not be in the same structure/reactor, and i wouldn't know how to do it with maven per-se. However, you can easily do it with a little ant script that can be integrated in your maven structure.

The Cobertura Ant library has a merge task that can merge a number of .ser files (generated by the runtime execution of your instrumented code). This will generate a combined .ser file for which you can generate a xml or html report from.

Let me know if you need more pointers.

Meadow answered 6/11, 2013 at 14:57 Comment(2)
Some of the projects are mvn project and some of them are ant project. I'm only interested in the overall code coverage results across all projects. I'm trying to write a little parser to parse the results in coverage.xml files. Would you know is there a tool can help me doing this?Silky
I don't. But again, normally you get the coverage.xml files from generating the report from the raw .ser file. Cobertura provides the command to accurately merge the .ser files, and then you can generate your xml (or html) report. So in short, you're better off merging the .ser files first and then generate an aggregate .xml report, rather than trying to merge the .xml reports. That is the cobertura model at least.Meadow
S
1

In another question a responder gave a link to a python script they had written that did what you are asking, I moved that "xml combiner" to a gist that is located here

Sharenshargel answered 8/5, 2015 at 13:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.