一.实现方式
创建个单独的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