Maven的Java 8项目代码覆盖率 [英] Maven's code coverage for Java 8 project
本文介绍了Maven的Java 8项目代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为我的Java 8 Maven项目创建代码覆盖率报告。我使用Cobertura时遇到问题,因为它无法处理Java 8语法。
任何熟悉解决方法的人?任何其他Maven插件?
I want to create a code coverage report for my Java 8 Maven project. I've got a problem with using Cobertura because it fails to handle Java 8 syntax. Anyone familiar with a workaround? Any other Maven plugin?
推荐答案
使用 JaCoCo ,适用于Java 8.
Use JaCoCo which works on Java 8.
这是我的pom中的插件XML:
Here is the plugin XML from my pom:
<build>
...
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules><!-- implementation is needed only for Maven 2 -->
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
<limits><!-- implementation is needed only for Maven 2 -->
<limit implementation="org.jacoco.report.check.Limit">
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.60</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
...
</build>
它还与Jenkins等持续集成系统有很好的集成
It also has good integration with Continuous Integration Systems like Jenkins
这篇关于Maven的Java 8项目代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文