views:

1333

answers:

2

Hello everybody,

i have a maven project with 4 modules - 3 of them contain code and some tests (testing equals and hashcode of the classes) whereas the 4th module is for testing the 3 other modules.

Now i want to run the cobertura code coverage tool to get an overview which classes are well tested and which are not. I did some investigations on that topic and it seems that cobertura is not aware of generating the right code coverage percentages and line coverages, if some sources which are tested are located within other modules.

I have read over some links like SeamTestCoverageWithCobertura and foobar.lacoctelera.net/post/2008/09/15/uso-del-plugin-cobertura-dentro-un-proyecto-multi-modulo-en but there has to be an out of the box solution. Can anybody report some new directions on this topic? Or are there bether tools like cobertura? I've stumbled upon emma but this tool does not offer line coverage...

+1  A: 

There are a few plugins that aggregate Cobertura (and other) reports. Check out the sonar and XRadar plugins. There is also the dashboard plugin, but it is a bit clunky.

FWIW Emma does do line coverage.

Rich Seller
+4  A: 

According to MCOBERTURA-65, the maven cobertura plugin still doesn't know how to aggregate reports of sub-modules into a consolidated one. Some work has been done to implement a merge target on the maven cobertura plugin (see MCOBERTURA-33) but this code hasn't been included in the plugin yet. I didn't test the patch myself and can't say if it's worth a try.

In consequence, lots of people indeed suggest to use the maven dashboard plugin but I'd personally stay far away from it as it isn't very satisfying on the long term and I faced lots of issues with it (technical problems, lost of history,...). Instead, I warmly recommend Sonar. Have a look at Nemo, a public instance of the last version of Sonar, for a live demo of this tool. See for example the Commons Digester project and the drill down of code coverage.

Pascal Thivent
so sonar is aware of multi-module code coverage?
pangratz
That's why I added a link to Nemo. Check for example http://nemo.sonarsource.org/project/index/commons-digester:commons-digester and the drill down: http://nemo.sonarsource.org/drilldown/measures/51834?metric=coverage
Pascal Thivent
Sonar will not show that code in the first three modules is covered by code in the fourth module. It simply aggregates the 4 completely separate and incomplete reports.
Craig P. Motlin