Filtering methods from code coverage

734 views
Skip to first unread message

Сергей Капралов

unread,
Feb 27, 2018, 4:46:07 PM2/27/18
to JaCoCo and EclEmma Users
Good day.

I have a tool, which besides other things generates equals and hashCode methods for classes (it's my own tool, which is not somehow related or dependent on lombok or similar stuff). And my intention is to make somehow these methods excluded from JaCoCo coverage reports. What options do I have in JaCoCo latest version?

Investigating opportunities on subj, described in https://github.com/jacoco/jacoco/wiki/FilteringOptions, I found out these potential ways of solving the problem:
1. Acceptable way for me would be to annotate equals and hashCode with some @ExcludeFromCodeCoverage and call it a day, but as I got it from https://github.com/jacoco/jacoco/issues/14, feature perspectives looks quite shady for me (or maybe I got it wrong?).
2. There is a dirty hacky way which works for me in 0.8.0 - to create a fake annotation lombok.Generated in the project and annotate equals/hashCode with it. But it is... well... dirty.
...
Any other options?

Marc Hoffmann

unread,
Mar 1, 2018, 3:30:02 AM3/1/18
to jac...@googlegroups.com

Hi,

actually option 2 is the only one that works with the current release: Annotate with one of the existing annotations @lombok.Generated or @groovy.transform.Generated. If you define the annotations yourself make sure the retention is CLASS.

If future versions of JaCoCo may come with their own annotation (like @ExcludeFromCodeCoverage) would a dependency on this JaCoCo annotations work better for you?

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/cb99baa8-8ff2-43a9-ac88-0bb2383ea73b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

Сергей Капралов

unread,
Mar 6, 2018, 10:01:28 AM3/6/18
to JaCoCo and EclEmma Users
> If future versions of JaCoCo may come with their own annotation (like @ExcludeFromCodeCoverage) would a dependency on this JaCoCo annotations work better for you?
A bit better, yes.

Honestly, the best option for me would be to have some "excludes" patterns in build plugins. I saw this https://github.com/jacoco/jacoco/wiki/FilteringOptions#filters-based-on-excludes-configuration explaination but still haven't got it how annotations way makes it different.

четверг, 1 марта 2018 г., 11:30:02 UTC+3 пользователь Marc R. Hoffmann написал:
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages