Jacoco - ignore MyClass.1

1.3k views Asked by At

How can *.1 classes be ignored in Jacoco coverage?

I have the following in my POM:

<execution>
  <id>JaCoco Coverage Enforcement</id>
  <phase>verify</phase>
  <goals>
    <goal>check</goal>
  </goals>
  <configuration>
  <dataFile>${project.build.directory}/coverage-reports/jacoco-unit.exec</dataFile>
  <excludes>
    <exclude>**/MyClass.**</exclude>
  </excludes>
  <rules>
    ...
  </rules>
</execution>

However, I get the following error message:

[WARNING] Rule violated for class com.mypackage.MyClass.1: lines covered ratio is 0.00, but expected minimum is 0.85

Update 12/19

Here's what's in the folder structure:

$ find . -iname 'MyClass*class'
./target/classes/com/mypackage/MyClass$1.class
./target/classes/com/mypackage/MyClass.class
1

There are 1 answers

0
Godin On BEST ANSWER

Exclusion pattern for verify goal can be **/MyClass$** if you want to exclude only file MyClass$1.class (note the dollar sign in place, where you had the dot). If you want to exclude both MyClass.class and MyClass$1.class, then pattern can be **/MyClass**.