Annotations to suppress coverage?

51 views
Skip to first unread message

Mark Palmer

unread,
Sep 22, 2020, 6:10:03 PM9/22/20
to JaCoCo and EclEmma Users

I saw some notes about the Generated annotation being used to suppress coverage for generated code.

Are there annotations for suppressing non-generated code?  Or is the only option exclude classes/methods from the report?

Thanks.

-Mark

Marc Hoffmann

unread,
Sep 23, 2020, 3:01:59 AM9/23/20
to jac...@googlegroups.com
Hi Mark,

any annotation that contains “Generated” in its name will cause filtering of the respective method or class.

There is no specific annotation for manual tagging.

As Evgeny once proposed a possible hack is to define a annotation called “CoverageShouldNotBeGenerated” ;)

Cheers,
-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/527559e2-2d87-4603-95f7-0901889ac621n%40googlegroups.com.

Mark Palmer

unread,
Sep 23, 2020, 8:21:42 AM9/23/20
to jac...@googlegroups.com
Thanks for the reply.  Is this something that is being looked into?

Aside from classes/methods, I'm wondering if anyone has asked for suppressing coverage for "blocks" - like, annotations for start/stop.

While it is a misuse of Generated, that seems to be the only currently available option to suppress coverage for code.

I know that classes/packages can be excluded from coverage via JaCoCo settings.  Can methods be excluded the same way?  I don't think I've ever seen this done before.

-Mark


You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/L8oYm3cRAw0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/B1CFBB18-3E91-4E81-959F-1EA96D66DCD3%40mountainminds.com.

Marc Hoffmann

unread,
Sep 23, 2020, 8:27:21 AM9/23/20
to jac...@googlegroups.com
Hi,

no, we’re not planning to support manual tagging. Exactly for the reason you give: Users are then expect to tag blocks, specific branches etc.

Only classes (i.e. class files) can be excluded during report generation.

Regards,
-marc


Mark Palmer

unread,
Oct 6, 2020, 1:13:21 PM10/6/20
to JaCoCo and EclEmma Users
I'm sorry - I think I misread this the first time, and misunderstood what the "CoverageShouldNotBeGenerated" hack was all about.

I think you are saying that we can define our own annotation and as long as it has the word "Generated" in it, JaCoCo will suppress coverage for the class/method that has the annotation.

Is that the case?

-Mark

Marc Hoffmann

unread,
Oct 7, 2020, 3:24:32 AM10/7/20
to jac...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages