【发布时间】:2019-01-29 20:17:03
【问题描述】:
我已经成功地将 JaCoCo 添加到我的项目中,它工作正常,但由于某种原因它不允许我排除一个类:src/main/java/com/example/Main.java
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<skip>false</skip>
<haltOnFailure>true</haltOnFailure>
<rules>
<rule>
<element>BUNDLE</element>
<excludes>
<exclude>com/example/Main.*</exclude>
</excludes>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.60</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
我已经尝试了网站中的其他问题,但在排除单个班级时,没有一个对我有用。执行上述代码后,我得到以下输出,其中包含 Main 类,这是我想避免的:
提前致谢
【问题讨论】:
标签: maven unit-testing jacoco cobertura jacoco-maven-plugin