Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cobertura-maven-plugin excludes configuration

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?

like image 826
Dmitrii Pisarenko Avatar asked Mar 05 '13 21:03

Dmitrii Pisarenko


1 Answers

After a lot try and fail I got it working.

  1. Edit the pom.
  2. mvn clean test-compile
  3. mvn cobertura:cobertura
  4. Reopen the page from Firefox. (make sure the page is not cached)

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

like image 179
marcandreuf Avatar answered Nov 11 '22 17:11

marcandreuf