Jacoco聚合测试报告实现(多module报告汇总)

一.实现方式

创建个单独的module,依赖需要生成测试报告的module,然后配置该module的jacoco插件生成聚合报告即可

二.pom.xml配置

    <dependencies>
        <dependency>
            <groupId>zzq</groupId>
            <artifactId>spring-boot-sonarqube-jacoco-jmockit</artifactId>
            <version>${revision}</version>
        </dependency>

        <dependency>
            <groupId>zzq</groupId>
            <artifactId>spring-boot-ribbitmq</artifactId>
            <version>${revision}</version>
        </dependency>

        <dependency>
            <groupId>zzq</groupId>
            <artifactId>spring-boot-cache-caffeine</artifactId>
            <version>${revision}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!--jacoco 单元测试覆盖率(聚合测试报告)-->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report-aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

三.执行mvn test命令后的效果

在这里插入图片描述

四.浏览器访问index.html文件查看效果

在这里插入图片描述

源码地址:https://github.com/philzq/zzq/tree/master/spring-boot/spring-boot-sonarqube-jacoco-jmockit-aggregate

猜你喜欢

转载自blog.csdn.net/qq_33594101/article/details/106075742