I am using JaCoCo and it is considering methods generated by Lombok (generated in the bytecode, not trace of them in the source code). How can I configure JaCoCo to ignore them?
You can set lombok. addLombokGeneratedAnnotation = true into lombok. config in the root of project. After that, all Lombok-generated code will be ignored by Jacoco.
Lombok will eventually automatically add this annotation to all generated constructors, methods, fields, and types. As per the docs, @Generated annotation is automatically added by Lombok for the generated code. Apart from that, @Generated doesn't generate any code like @Getter or @Setter does.
Instruction coverage provides information about the amount of code that has been executed or missed. This metric is completely independent from source formatting and always available, even in absence of debug information in the class files.
Why does the coverage report not show highlighted source code? Make sure the following prerequisites are fulfilled to get source code highlighting in JaCoCo coverage reports: Class files must be compiled with debug information to contain line numbers. Source files must be properly supplied at report generation time.
Also another way to exclude lombok generated classes since jacoco 0.8.0 and lombok 1.16.14.
Luckily, beginning with version 0.8.0, Jacoco can detect, identify and ignore Lombok-generated code. The only thing you as the developer have to do is to create a file named lombok.config
in your directory’s root and set the following flag:
lombok.addLombokGeneratedAnnotation = true
This adds the annotation lombok.@Generated
to the relevant methods, classes and fields. Jacoco is aware of this annotation and will ignore that annotated code.
Please keep in mind that you require at least version 0.8.0 of Jacoco and v1.16.14 of Lombok.
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