You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Beans marked as @lazy are inadvertedly initialized when running spock-spring tests. I suspect the culprit is SpringMockTestExecutionListener:54. @lazy autowiring works fine, however, classes and @beans, annotated with @lazy, are loaded due to the invocation of applicationContext.getBean(...)
When running LazyBeanInitializedSpec, you will notice an "I AM INITIALIZED" message in console log.
When running LazyBeanNotInitializedSpec (which is a regular, non spring spock test), this message won't appear.
Issue description
Beans marked as @lazy are inadvertedly initialized when running spock-spring tests. I suspect the culprit is SpringMockTestExecutionListener:54. @lazy autowiring works fine, however, classes and @beans, annotated with @lazy, are loaded due to the invocation of
applicationContext.getBean(...)
How to reproduce
I've uploaded a small project that has this issue reproduced in tests:
https://github.com/jiallombardo/test-spock-spring
When running LazyBeanInitializedSpec, you will notice an "I AM INITIALIZED" message in console log.
When running LazyBeanNotInitializedSpec (which is a regular, non spring spock test), this message won't appear.
Additional Environment information
Java/JDK
java -version
8Groovy version
groovy -version
2.4.4Gradle
gradle -version
3.1Operating System
IDE
Build-tool dependencies used
Gradle/Grails
The text was updated successfully, but these errors were encountered: