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
{{ message }}
Repository navigation
A @SpyBean on the output of a FactoryBean is not reset #31204
Repository SpyBeans seem to keep stubs when context is reused on other test class, since 2.6.x up to 2.7.0, at least
This does not seem to happen with regular beans (i.e, not JPA proxies Repository interfaces), and it seems caused by MockReset.get(bean) not returning AFTER in objectResetMocksTestExecutionListener.resetMocks, when it should. It returns NONE because SpringBootMockResolver does not find the target, apparently test.zip
.
Thanks for the sample, @nightswimmings. As far as I can tell, the problem is broader than proxied Spring Data Repository interfaces. It appears to apply whenever @SpyBean is used on the output of a FactoryBean.
@MockBean is not affected as when the mock is created, it's added to MockitoBeans from where it can be retrieved and reset. Also adding spies to MockitoBeans may be a solution but I'll need to give it and any potential unwanted side-effects some more thought.
Reacted by nightswimmings, Giovani Grifante and Stefano Cordio
Just chiming in to note that this is what's done for Spring Framework 6.2's @MockitoSpyBean, as the @MockitoBean and @MockitoSpyBean are covered by the same code for tracking in the framework version of MockitoBeans.
Activity
[-]Repository SpyBeans not reseting between tests[/-][+]A @SpyBean on the output of a FactoryBean is not reset[/+]wilkinsona commentedon May 30, 2022
Thanks for the sample, @nightswimmings. As far as I can tell, the problem is broader than proxied Spring Data
Repositoryinterfaces. It appears to apply whenever@SpyBeanis used on the output of aFactoryBean.@MockBeanis not affected as when the mock is created, it's added toMockitoBeansfrom where it can be retrieved and reset. Also adding spies toMockitoBeansmay be a solution but I'll need to give it and any potential unwanted side-effects some more thought.Close spring-projects#31204: Add documentation for command line publish
simonbasle commentedon Aug 13, 2024
Just chiming in to note that this is what's done for Spring Framework 6.2's
@MockitoSpyBean, as the@MockitoBeanand@MockitoSpyBeanare covered by the same code for tracking in the framework version ofMockitoBeans.wilkinsona commentedon Nov 6, 2024
Moved to 3.3.x to avoid potentially destabilising 3.2.x before its final OSS release.
Fix resetting of spied FactoryBean output