2

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 
2
  • Could you please clarify what do you have on disk - file MyClass.1.class or file 1.class in directory MyClass? Actually both look weird in case of plain Java. I'm guessing that you use some bytecode generation tool that generates such classes? Commented Dec 18, 2016 at 21:42
  • I added the disk data above. I'm actually not doing anything too funky and the project is a pretty simple Spring Boot app running under Java 8. Commented Dec 19, 2016 at 20:45

1 Answer 1

6

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**.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.