1

I use Coveralls in a Java project with Maven to create a coverage report for my project and I want to avoid some classes from being included in the coverage computation.

Now, I think that I the build phase I can exlcude the class, e.g. MyClassTest.java as follows:

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.5.201505241946</version>
    <executions>
        <execution>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
        <execution>
            <id>report</id>
            <phase>test</phase>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <excludes>
            <exclude>**/*MyClassTest.java</exclude>
        </excludes>
    </configuration>
</plugin>
<plugin>
    <groupId>org.eluder.coveralls</groupId>
    <artifactId>coveralls-maven-plugin</artifactId>
    <version>4.1.0</version>
</plugin>

Anyway, the coverage doesn't decrease, so I guess that the class MyClass is still computed from the Jacoco report.

In the travis file I call the report phase as follows:

- mvn clean test jacoco:report coveralls:report

Any idea?

mat_boy
  • 12,998
  • 22
  • 72
  • 116

1 Answers1

1

My bad!

First the .java has to be removed and replace with .class as correctly suggested by Tunaki.

Second, I don't have to exclude the test class, but the class that I don't want to measure in the coverage! So it is:

    <excludes>
        <exclude>**/*MyClass</exclude>
    </excludes>

instead of

    <excludes>
        <exclude>**/*MyClassTest.java</exclude>
    </excludes>
Community
  • 1
  • 1
mat_boy
  • 12,998
  • 22
  • 72
  • 116