Diffblue does not work with lombok

Diffblue requires getters and setters, and also constructor for final attributes. These are easily provided with lombok’s @Data (Getter/Setter) and @RequiredArgsConstructor.

In my project we use these extensively before I got to know about diffblue. Requiring me to delombok the whole project just to get diffblue to work is not an option.

Please is there anything can be done about this.

T

Hi @mattae

Thanks for getting in touch and thanks for telling us about your use case - I am sorry that we haven’t been able to help you out of the box, but we will see what we can do to help here.

A few of our engineers are having a conversation about this now and we will put together a few suggestions and get back to you soon

Thank you once again,

Matthew
Head of Product @ Diffblue

Hi mattae,

We tried to understand what problems you are seeing with Cover on projects that use Lombok yesterday, but for all the examples we tried, Cover produced tests just as expected. In particular, we easily recognize Lombok-generated getters and setters, and use them in tests like we would for hand-written getters and setters. We have tried this with different Lombok settings as well, and both with code compiled by Maven and from IntelliJ directly.
Would you happen to have a concrete example of what doesn’t work for you that you can share with us? We’d love to get to the bottom of this!

Thanks in advance,
Johannes

Thank you for the feedback.

I’m not sure if there are any particular configurations to be made, but I have lombok in my maven dependency and installed Intellij lombok plugin.

When I select “write test” for a class, if there is a reference to lombok getter or setter within the class, or absence of constructor for the class to be tested, it throws an error, but works well for classes without lombok use

Thank you

Just out of curiosity, does test case generation work for that class when you de-lombikify it? I’m wondering whether this is actually a Lombok issue - my first guess would be that the class in question just happens to be hard to test for Cover, and the fact that it uses Lombok is a red herring.

Yes, it works when I de-lombok it

Can you share any information about the class in question? It would be extremely helpful if we had an example on which we could reproduce the problem.

Thank you.
I think it’s a problem with Intellij 2020.3 and lombok plugin.

https://stackoverflow.com/questions/65128763/java-you-arent-using-a-compiler-supported-by-lombok-so-lombok-will-not-work-a

I’ll change the version and give feedback

Thank you

That problem definitely sounds like it could be related. Cover relies on having accurate compiled bytecode, and this sounds like it would cause compilation problems.

Thank you, that helped a lot.

I’ll continue to evaluate Diffblue