Consider a multi-module maven project
Parent
pom.xml
common
src->main->java->a -> b
SomeUtil.java
pom.xml
service
src->main->test->p->q
SomeServiceIT.java
pom.xml
Say service has a dependency on common, and service has SomeServiceIT which indirectly tests SomeUtil in common.
The coverage report produced shows 0% coverage for SomeUtil where it should have shown atleast some coverage.
How do I fix this ?
I am using following plugins
jacoco-maven-plugin -> 0.8.1
maven-surefire-plugin -> 2.22.0
maven-failsafe-plugin -> 2.22.0
sonar-maven-plugin -> 3.2
Following is my configuration
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>
<configuration>
<destFile>${project.basedir}/../target/coverage-reports/jacoco.exec</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-merge</id>
<phase>post-integration-test</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileset>
<directory>${project.build.directory}/../target/coverage-reports/</directory>
<includes>
<include>*.exec</include>
</includes>
</fileset>
</fileSets>
<destFile>${project.build.directory}/../target/coverage-reports/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>jacoco-site</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- Separates the unit tests from the integration tests. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.failsafe.plugin.version}</version>
<configuration>
<forkCount>3C</forkCount>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>