7

My maven project directory structure is as follows:

parent
  -child
    -src/java
    -src/test <!-- unit tests -->
    -pom.xml
  -integration_test
    -src/test
    -pom.xml
  -report
    -pom.xml
  -pom.xml

Since integration tests and source code are in different modules I used Jacoco report-aggragate (report module).

Parent pom.xml

        <profile>
            <id>codecoverage-it</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.8.4</version>
                        <executions>
                            <execution>
                                <id>prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>prepare-agent-integration</id>
                                <goals>
                                    <goal>prepare-agent-integration</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

report module pom.xml

<dependencies>
        <dependency>
            <groupId>###</groupId>
            <artifactId>child</artifactId>
            <version>${project.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>###</groupId>
            <artifactId>integration_test</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>overage-aggregate</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>report-aggregate</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>report-aggregate</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

The unit tests code coverage report is displayed correctly, but for integration tests even though the tests are executed, the code coverage is given as 0

2

0