Why does cobertura report code coverage as zero for all but one module in the maven multi-module project?

I am trying to generate a code coverage report for our multi-module maven project using cobertura. After running mvn clean and then running the mvn package. Then, in one of the modules where we run the JUnit tests, the coverage report generated for this module is correct as expected. But coverage only covers a few packages. Not all packages are covered. Remember that this is a multi-module project with one parent POM and each child module having its own POM. Should I also include the details of the cobertura maven plugin in each of these child POMs?

However, the individual coverage report of a particular module, generated in other directories / target / site / cobertura, is reported as zero both for line coverage and for branch coverage.

Am I missing something in my parent POM ?, I did not make any changes to any of the child POMs in the directories. please let me know how to create a code coverage report for a project with several maven modules using coberture.

This is what my parent POM looks like.

<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.5.1</version> <configuration> <formats> <format>html</format> <format>xml</format> </formats> </configuration> <inherited>true</inherited> <executions> <execution> <phase>package</phase> <goals> <goal>cobertura</goal> </goals> </execution> </executions> </plugin> 

...

 <dependencies> <dependency> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.5.1</version> <type>plugin</type> <scope>package</scope> </dependency> </dependencies> 

Thanks!

0
source share
1 answer

According to the docs, there is a difference between plugins that run as part of an assembly and plugins that run as part of reports: http://maven.apache.org/guides/mini/guide-configuring-plugins.html

your use of "executions" suggests that you have a plugin under "build", although it seems to refer to a "report" - according to the cobertura usage page: http://mojo.codehaus.org/cobertura-maven-plugin /usage.html

Try to completely remove the cobertura plugin from 'build' and instead place it under 'reporting':

 <project> <!-- project stuff--> <build> <!-- build stuff --> </build> <reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.2</version> <configuration> <formats> <format>html</format> </formats> </configuration> </plugin> </plugins> </reporting> </project> 

then run it either with

 mvn cobertura:cobertura 

or

 mvn site 
0
source

All Articles