我有一个maven多模块项目,我正在使用jacoco-maven进行代码覆盖率报告.不应该报告某些类,因为它们是Spring配置,我对它们不感兴趣.
我已经宣布了maven-jacoco插件如下:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
<configuration>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
<exclude>some.package.*</exclude>
<exclude>**/*Config.*</exclude>
<exclude>**/*Dev.*</exclude>
<exclude>some/package/SomeClass.java</exclude>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
问题是,当我执行mvn clean verifyjacoco时,仍会报告应该已被排除的类,因为我的xml配置指出了.如何正确配置?
我有一些Java代码,我想从代码覆盖中排除.我该怎么做?我希望能够添加注释.有没有办法配置或扩展jacoco(在gradle中使用)来使用它?
例:
public class Something
{
@ExcludeFromCodeCoverage
public void someMethod() {}
}
Run Code Online (Sandbox Code Playgroud) 我想知道我是否在我的代码中添加了注释,当有人试图反编译时,他们是否可以阅读我提出的评论?