简述
前提
idea + jdk + maven
步骤
pom.xml添加
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals><goal>prepare-agent</goal></goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals><goal>report</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
测试
执行mvn install命令,成功后生成*/target/site,网页打开*/target/site/jacoco/index.html
像测试代码覆盖率(53-36)/ 53 约等于 32%
备注
更多mockito请看:https://blog.csdn.net/sndayYU/article/details/103887552
测试相关请看:https://blog.csdn.net/sndayYU/article/details/103863847