jacoco代码覆盖率工具配置
参考文章:
https://blog.csdn.net/skh2015java/article/details/121775806
解决引入jacoco依赖并配置后,执行maven clean test未生成jacoco执行文件与报告的问题:
https://betheme.net/yidongkaifa/169829.html?action=onClick
maven配置:
<!-- jacoco depends-->
<!-- https://mvnrepository.com/artifact/org.jacoco/jacoco-maven-plugin -->
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
</dependency>
<!-- jacoco依赖-->
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<!-- jacoco-plugins-->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<!-- <configuration>-->
<!--<!– 生成不了jacoco.exec 放开注释试试 –>-->
<!-- <propertyName>jacocoArgLine</propertyName>-->
<!-- </configuration>-->
<executions>
<execution><id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals></execution>
<execution>
<id>default-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<skipTests>false</skipTests>
<!-- <forkMode>once</forkMode> 生成不了jacoco.exec 放开注释试试 -->
<!-- <argLine>-Dfile.encoding=UFT-8 ${jacocoArgLine}</argLine>-->
<includes>
<include>**/*Test.java</include>
</includes></configuration>
</plugin>
执行后效果:
脑子不够用当然只能脚踏实地的做事情!