JUnit not working with Lombok - annotation processing doesn't seem to work for test classes

What Gradle version are you using? This issue was seen in Gradle version 5.4.1.

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 could try the dependency as below,

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

Reference: https://projectlombok.org/setup/gradleLombok doc

More information can be found in the below location,

https://github.com/rzwitserloot/lombok/issues/1945


You've used incorrect dependency testAnnotationProcessor it should be annotationProcessor, see lombock-gradle doc. After fixing gradle file you'll be able to build it with terminal. Also it could be still failed in IDE because of lombok requires to enable annotation processing for IDE (check your IDE documentation).