不幸的是,这几乎没有记录,但对我来说,当我手动添加 JaCoCo Maven 插件时出现了菜单条目:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</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.01</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
Maven 目标verify
运行覆盖率报告。如官方文档中所述,您还将拥有覆盖窗口。
不幸的是,插件或集成似乎有点问题,因为您可以运行测试并在“测试结果 NB”窗口中查看其结果,或者查看覆盖范围......似乎有两种运行测试的方法,而我没有找到了同时做这两件事的方法。