-
Notifications
You must be signed in to change notification settings - Fork 25
Description
When using a bean factory for the test scope, lifecycle methods are not invoked on beans that inherit from a superclass containing such methods.
In contrast, when running the application with the default scope, the behavior is as expected, and the methods annotated with e.g. @PostConstruct
are invoked correctly.
It appears that the generated TestBeanFactory$DI
build_
-methods are missing the builder.addPostConstruct()
statement.
Here's a minimal example project demonstrating this issue: https://git.iem.de/jan/avaje-generator-bug-example
In this project, the main application correctly resolves the greeting message, whereas the unit test fails to do so.
So far, I haven't been able to pinpoint the exact location in the inject-generator that causes this behavior.
One interesting detail I’ve noticed: The issue seems to depend on the naming of the subclass. If the subclass name ends with the name of the superclass, the problem does not occur. You can test this by renaming ServiceCreator
to just Service
in the provided example.
Thanks for your work on this project!