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.
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.
I got it working with:
<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>
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