jacoco / jacoco

:microscope: Java Code Coverage Library
https://www.jacoco.org/jacoco/
Other
4.2k stars 1.15k forks source link

Allow exclusions per rule or per limit #1495

Open joaoluis89 opened 1 year ago

joaoluis89 commented 1 year ago

THIS IS A BUG TRACKER ONLY. FOR QUESTIONS PLEASE CHECK FAQ OR USE FORUM:

http://www.jacoco.org/jacoco/trunk/doc/faq.html

https://groups.google.com/forum/?fromgroups=#!forum/jacoco

Please understand that ISSUES WITHOUT FOLLOWING INFORMATION WILL BE CLOSED WITHOUT COMMENTS! Thank you for filling feature request!

Scenario

Current Behaviour

Actually we can make exclusions from coverage in general

Wanted Behaviour

We faced some chalenge where we would like to keep the limit of line coverage to a class, but exclude it from branch coverage. As a matter of fact, we are using map structs that verifies parameter nullity as a guard condition on its generated classes. We would like to enforce the line coverage of it, but prevent the branch coverage of happening

Possible Workarounds

enable excludes on limits or on rules (although on rules would bring up some concerns about how the execution of the coverage is calculated)

marchof commented 1 year ago

@joaoluis89 For each rule you can specify includes and excludes pattern for the respective entity (e.g. class), see documentation:

https://www.jacoco.org/jacoco/trunk/doc/check-mojo.html#rules