Exclude Setters and Getters in JaCoCo Code Coverage

前端 未结 3 1330
南笙
南笙 2021-02-13 13:46

With the cobertura-maven-plugin setters and getters can be excluded from code coverage using the ignoreTrivial option. Is there also such a possibility

3条回答
  •  被撕碎了的回忆
    2021-02-13 14:28

    From JaCoCo 0.8.0, it is possible to exclude the getters / setters (and also toString(), equals(), ...) automatically generated by Lombok from the coverage metrics thanks to filtering options :

    Lombok

    Methods annotated with @lombok.Generated (generated by Lombok getters, setters, equals, hashcode, toString, etc) - Done in 0.8.0

    To that end, you will first need to create a lombok.config file located for example at the root folder of your projet, with the following contents :

    lombok.addLombokGeneratedAnnotation = true
    

    The @Generated annotation will be added to the setters / getters, etc. and will be skipped in the coverage analysis.

提交回复
热议问题