Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven cobertura plugin - one report for multimodule project

I'm using maven cobertura plugin to report code coverage in my multimodule project.

The problem is that I don't know how to generate one report for all modules in project.

So far I have generated separate reports for every module, but it would be nice to have one report for whole project.

My parent pom configuration:

   <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.4</version>
        <inherited>true</inherited>
        <executions>
            <execution>
                <phase>test-compile</phase>
                <goals>
                    <goal>clean</goal>
                    <goal>cobertura</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
like image 835
Lukasz Moren Avatar asked Sep 22 '10 10:09

Lukasz Moren


People also ask

Why is cobertura code covered?

A code coverage utility for Java. Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. It is based on jcoverage.

What is cobertura ser?

Simply put, Cobertura is a reporting tool that calculates test coverage for a codebase – the percentage of branches/lines accessed by unit tests in a Java project.


1 Answers

The plugin has been updated since this question was asked (and last answered) to now enable aggregated reporting, via the aggregate configuration property in the parent POM.

This produces the aggregated coverage report at target/site/cobertura/index.html which will include all modules.

(Each module will also have it's own report produced, if that is of any use.)

Parent pom.xml

<modules>
    <module>moduleA</module>
    <module>moduleB</module>
    <module>moduleC</module>
<modules>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <check/>
                    <formats>
                        <format>html</format>
                        <format>xml</format>
                    </formats>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
            ...
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
        </plugin>
    </plugins>
...
</build>
like image 191
vegemite4me Avatar answered Nov 16 '22 01:11

vegemite4me