I'm trying to ignore some generated classes, and the classes get ignored fine. But if those classes have inner classes, those classes still get included, despite the parent class being excluded. This is my configuration:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<excludes>
<exclude>**/*DB.*</exclude>
<exclude>**/*DTO.*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
Attempting to use the standard Java name convention of ParentClass.NestedClass by excluding **/*DB.*.*
did not help.
Starting from JaCoCo 0.8. 2, we can exclude classes and methods by annotating them with a custom annotation with the following properties: The name of the annotation should include Generated. The retention policy of annotation should be runtime or class.
The easiest way to exclude code from code coverage analysis is to use ExcludeFromCodeCoverage attribute. This attribute tells tooling that class or some of its members are not planned to be covered with tests. EditFormModel class shown above can be left out from code coverage by simply adding the attribute.
The check goal has a skip parameter: eclemma.org/jacoco/trunk/doc/check-mojo.html#skip - so it would be -Djacoco. skip=true - it seems this skips all of the jacoco goals. If you don't want that maybe temporarily move the check goal into a profile you can activate when back on track?
Edit Configurations > Select Code Coverage tab > then adding the package or class I want to be excluded or include only in the code coverage report.
After some searching, I found the answer myself. As it wasn't easily googleable, I'm putting it here for posterity's sake:
The syntax mirrors that of the compiled Java naming convention:
<configuration>
<excludes>
<exclude>**/*DB.*</exclude>
<exclude>**/*DB$*.*</exclude>
<exclude>**/*DTO.*</exclude>
<exclude>**/*DTO$*.*</exclude>
</excludes>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With