HI Team,
We want to exclude the jacoco coverage for certain methods from some of the classes. For that we using the custom annotation based feature introduced in jacoco plugin from 0.8.2 version onwards.
For us we are using this plugin both in eclipse and through jenkins but unfortunately it is not excluding the annotated methods from coverage. We are getting jacoco coverage including these methods too.
Eclipse Version: 2021-09 (4.21.0), Build id: 20210910-1417
Jenkins jacoco plugin version: 3.3.1.
Maven version: 3.6.1
Running the below cmd from eclipse to generate jacoco code coverage:
clean org.jacoco:jacoco-maven-plugin:prepare-agent install jacoco:report
From jenkins:
clean -B -U -T 2 org.jacoco:jacoco-maven-plugin:prepare-agent pmd:pmd pmd:cpd findbugs:findbugs -Dmaven.test.failure.ignore=true package
One thing to mention here is that in my pom i dont added jacoco-maven-plugin explicitly and just running that jacoco plugin directly from arguments like above.
Custom annotation created like below:
@Retention(RUNTIME)
@Target(METHOD)
public @interface Generated {}
I tried with other name like ExcludeMethodFromJacocoGeneratedReport but no luck.
Usage of annotation example in my code:
@Generated
public void method() {}
Another example:
@ExcludeMethodFromJacocoGeneratedReport
public void method() {}
Let me know what is missing here.
Regards-
Ankit