我有一个带有测试用例的 Maven 项目DefaultViewTypeToFragmentMapperTest.java
在目录中/src/test/java/test/com/mycompany/myproduct/android/viewtype2fragmentmapper/
.
我希望将此测试用例从单元测试覆盖率计算中排除。为了达到这个结果,我这样配置插件:
<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>
但我仍然在报道报告中看到上述课程。
我该如何修复它,使测试用例不会出现在报告中,并且不考虑其覆盖率(根据报告为 0%)?
经过多次尝试和失败后,我成功了。
- 编辑 pom.xml
- mvn clean 测试编译
- 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”更改为您要从报告中排除的包名称。
我希望它有帮助,
马克·安德鲁
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)