JaCoCo: exclude generated methods (using it with Lombok)

左心房为你撑大大i 提交于 2019-12-03 09:55:10

Use the excludes tag provide by jacoco.

            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.4.201502262128</version>
            <configuration>
                <excludes>
                    <exclude>**/config/**</exclude>
                    <exclude>**/model/**</exclude>
                    <exclude>**/item/**</exclude>
                </excludes>
            </configuration>
ebonnet

Also another way to exclude lombok generated classes since jacoco 0.8.0 and lombok 1.16.14 see: https://www.rainerhahnekamp.com/en/ignoring-lombok-code-in-jacoco/

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!