Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude an anonyomous class from jacoco?

I am seeing class CacheConfig.new CacheLoader() {...} in my jacoco report. Is there a way to exclude it?

like image 832
Nelson Avatar asked Jul 01 '16 16:07

Nelson


2 Answers

To exclude all anonymous classes in CacheConfig, it should work if you exclude CacheConfig$1*.class, CacheConfig$2*.class, CacheConfig$3*.class, CacheConfig$4*.class, CacheConfig$5*.class, CacheConfig$6*.class, CacheConfig$7*.class, CacheConfig$8*.class, CacheConfig$9*.class as anonymous classes are compiled to CacheConfig$1.class, CacheConfig$2.class and so on.

Excluding CacheConfig$*.class will not work, as it would exclude all inner classes, not only anonymous ones. If you want to exclude all inner classes, CacheConfig$*.class is ok to be used.

If you only want to exclude this one anonymous class, you can of course also exclude CacheConfig$1.class or what number it has. You can see this from the link that the label CacheConfig.new CacheLoader() {...} in the report is pointing at. But be aware, if you add another anonymous class before this one in CacheConfig, numbers will shift accordingly.

like image 150
Vampire Avatar answered Oct 05 '22 23:10

Vampire


Adding **/*$*.* in excluded list ignores all anonymous binders and classes in your classes

like image 33
parohy Avatar answered Oct 06 '22 00:10

parohy