How would I add an annotation to exclude a method from a jacoco code coverage report?

后端 未结 4 934
庸人自扰
庸人自扰 2020-12-14 16:13

I have some code in Java that I want to exclude from code coverage. How would I do this? I want to be able to add an annotation. Is there a way to configure or extend jacoco

4条回答
  •  感情败类
    2020-12-14 16:19

    Tl;dr

    Use annotation @lombok.Generated from Lombok.

    Explanation

    Jacoco integrates with Lombok. Code generated by Lombok is excluded from Jacoco coverage by default (see Release 0.8.0 in Jacoco changelog). You can misuse lombok.Generated at your method for it being excluded from the coverage report.

提交回复
热议问题