Home>

Measure code coverage using Jacoco.
The corresponding application uses lombok.

There are getters and setters generated by lombok.
I would like to exclude it from the coverage.
Is there a good way to do it?

There was an explanation that filtered the site below,
I did not know what to do specifically.
Is lombok not supported? ?
https://github.com/jacoco/jacoco/wiki/FilteringOptions

There is a way to exclude it from coverage by specifying it in the package etc.
If there is a way to exclude only code generated purely in lombok, please let me know.

  • Answer # 1

    It seems that the jacoco side has responded.

    Methods annotated with @ lombok.Generated to better integrate with Lombok>= 1.16.14.Initial analysis and contribution by Rüdiger zu Dohna

    https://github.com/jacoco/jacoco/pull/513

  • Answer # 2

    >How to exclude only code generated purely in lombok

    I was worried and investigated the same thing, but as a conclusion, it seems that the function that works on jacoco side is not made.

    How to exclude only code generated by lombok lombok.config settings

    Createlombok.configin the same directory as maven's pom.xml

    lombok.config

    lombok.addLombokGeneratedAnnotation = true

    If you build the source in this state, the code from lombok will be annotated with@ lombok.Generated. This area is also written in the lombok project. Project Lombok-Configuration system

      

      Lombok can be configured to add @ lombok.Generated annotations to all generated nodes? Where possible;useful for JaCoCo (which has built in support), or other style checkers and code coverage tools:
          lombok.addLombokGeneratedAnnotation = true

    I've confirmed what I can do so far

    Start jacoco

    It seems like I'm testing the same functionality in this pull request on GitHub

    Exclude methods annotated with @ lombok.Generated

    The jacoco version used here is0.7.10-SNAPSHOT.

    However, the latest release version at this point (20171023) is0.7.9.

    I tried with the release version, but jacoco test exclusion did not work.