1

I have a huge code base configured using maven. My codebase is divided in different maven modules and thus I have a main pom file and each sub module has its own pom file. But still these modules call each other's functionality. Junit tests are written for each module. I am using Cobertura to generate code coverage. Its generating separate coverage report for each module. When Cobertura generate code coverage for module A and a perticular code from Module A is getting called by tests from module B. In this scenario Cobertura marks that code from Module A as uncovered. Is this the expected behavior? Or I have wrong configuration?

Maven - Cobertura Configuration in submodules:

build section:

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>${org.codehaus.mojo.cobertura-maven-plugin.version}</version>
            </plugin>

Reporting section:

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>${org.codehaus.mojo.cobertura-maven-plugin.version}</version>
                <configuration>
                    <formats>
                        <format>xml</format>
                    </formats>
                </configuration>
            </plugin>

Command to run Cobertura report:

mvn cobertura:cobertura
halfer
  • 19,824
  • 17
  • 99
  • 186
amit
  • 181
  • 2
  • 4
  • 20

1 Answers1

2

I would suggest you to try JaCoCo code coverage tool for the run-time coverage generation, which is easier to implement and more expressive in terms of code covered[package,class,method,line]. It provides additional features compared to Cobertura. I tried JaCoCo and other tools and found JaCoCo generated reports more comprehensible and useful, compared to other.

Refer: https://confluence.atlassian.com/display/CLOVER/Comparison+of+code+coverage+tools Need to generate Code Coverage Reports using jacoco.exec file

Ranjan Kumar
  • 107
  • 1
  • 10