Jacoco
参考链接:
Jacoco是一个开源的覆盖率工具,针对java语言。
使用
Java项目中使用,可以参考下面的链接:
pom.xml中添加plugin:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<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>
maven打包阶段,需要enable test阶段:执行单元测试命令:mvn test
结果在target目录下生产jacoco.exec文件,表明jacoco正确执行
代码覆盖率的报表将会产生在下面的路径:
target/site/jacoco/index.html