Method coverage exclusion not working in eclipse and Jenkins using jacoco plugin version 0.8.2+

22 views
Skip to first unread message

Ankit Jain

unread,
Jan 3, 2022, 7:08:28 PM1/3/22
to JaCoCo and EclEmma Users
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

Marc Hoffmann

unread,
Jan 6, 2022, 3:51:47 PM1/6/22
to JaCoCo and EclEmma Users
Hi,

please note that the filtering is applied during report generation. AFAIK the Jenkins plugin has its own dependencies to specific JaCoCo versions. Please check which version is used there.

Regards,
-marc



--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/b5fcd816-1547-44ea-92e5-5d2a58f8a898n%40googlegroups.com.

Ankit Jain

unread,
Jan 6, 2022, 4:06:29 PM1/6/22
to jac...@googlegroups.com
HI Marc,

I do use the jenkins plugin which has jacoco version which provides this functionality.

Regards-
Ankit

Reply all
Reply to author
Forward
0 new messages