cobertura-maven-plugin排除配置 [英] cobertura-maven-plugin excludes configuration
问题描述
我在目录/src/test/java/test/com/mycompany/myproduct/android/viewtype2fragmentmapper/
中有一个带有测试用例DefaultViewTypeToFragmentMapperTest.java
的Maven项目.
I have a Maven project with a test case DefaultViewTypeToFragmentMapperTest.java
in the directory /src/test/java/test/com/mycompany/myproduct/android/viewtype2fragmentmapper/
.
我希望将此测试用例从单元测试覆盖率计算中排除.为了获得此结果,我将插件配置如下:
I want this test case to be excluded from unit test coverage calculation. In order to achieve this result, I configured the plugin like this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<instrumentation>
<excludes>
<exclude>test/co/**/*.class</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>
但是我仍然可以在覆盖率报告中看到上述课程.
But I still see the aforementioned class in the coverage report.
如何解决该问题,使测试用例不出现在报告中,并且不考虑其覆盖范围(根据报告为0%)?
How can I fix it such that the test case does not appear in the report and its coverage (0 % according to the report) is not taken into account?
推荐答案
经过多次尝试和失败,我终于开始使用它了.
After a lot try and fail I got it working.
- 编辑pom.
- mvn clean test-compile
- mvn cobertura:cobertura
- 从Firefox重新打开页面. (确保未缓存页面)
我可以和它一起工作:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<instrumentation>
<excludes>
<exclude>aaa/**/*.class</exclude>
<exclude>com/test/bbb/**/*.class</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>
将包名称的开头更改为"aaa",以将其排除在外. 将"bbb"更改为要从报告中排除的软件包名称.
Change 'aaa' with the beginning of the package name to be excluded. Change 'bbb' with your package name that you want to exclude from the report.
我希望它能对您有所帮助, 马克·安德鲁
I hope it helps, Marc Andreu
这篇关于cobertura-maven-plugin排除配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!