Lombok @getter not working in src/test/java package

For Lombok annotations in test source sets, you need to add Lombok to two dependency configurations:

testCompileOnly '...'
testAnnotationProcessor '...'

In the same way as compileOnly and annotationProcessor the first one makes the annotations available to the code and the second one activates annotation processing during compilation.


You didn’t post your build.gradle but I’m guessing you declared Lombok dependency as compileOnly, which only applies to main code. Also declare it as testCompileOnly.


I just reproduced the same issue which you faced, my gradle version is

Gradle Version : 5.4.1

To resolve this, in reference to the Lombok doc (https://projectlombok.org/setup/gradle) I changed the dependency as below.

    compileOnly 'org.projectlombok:lombok:1.18.8'
    annotationProcessor 'org.projectlombok:lombok:1.18.8'

You could take look at this https://github.com/rzwitserloot/lombok/issues/1945 for more info