Configure cobertura to ignore certain blocks of code
From what I have read from above question, there's no way in Cobertura to exclude given code part from being tested versus having coverage in tests.
Is that true? / Is it possible in any simmilar tool?
I'm usuing Lombok annotations @Getter
, @Setter
and so on, which are great, but they result in being 'red' in coverage report, even if I'm testing getter and setter methods. - I would like to do something with that... Is there any way to fix this?
Isn't it possible to first run delombok over the code under test, compile it and then instrument it by Cobertura?
Disclosure: I am one of the Project Lombok developers
Lombok adds a @javax.annotation.Generated
annotation (1). But this annotation has source
retention, i.e. your coverage tool can't see it any more :-(
Lombok 1.16.14 just fixed issue-1014 by adding an option to generate a @lombok.Generated
annotation instead; just configure lombok.addLombokGeneratedAnnotation
(2).
Cobertura can be configured to skip methods with some annotation, so most of the generated code won't count against your coverage.
JaCoCo doesn't provide a configuration mechanism to skip on certain annotations. Issue-15 tries to fix this (and much more) without requiring any configuration.
(1) If not disabled with lombok.addGeneratedAnnotation
which is now deprecated and should be replaced with lombok.addJavaxGeneratedAnnotation
(2) see lombok config
(3) see this comment
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With