即使执行测试,Jacoco报告汇总仍显示0覆盖

时间:2019-08-26 09:47:56

标签: integration-testing jacoco jacoco-maven-plugin

我的maven项目目录结构如下:

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

由于集成测试和源代码位于不同的模块中,因此我使用了Jacoco report-aggragate(报告模块)。

父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>

报告模块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>

单元测试代码覆盖率报告正确显示,但是对于集成测试,即使执行了测试,代码覆盖率也被指定为0

0 个答案:

没有答案