Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A @SpyBean on the output of a FactoryBean is not reset #31204

Closed
nightswimmings opened this issue May 30, 2022 · 3 comments
Closed

A @SpyBean on the output of a FactoryBean is not reset #31204

nightswimmings opened this issue May 30, 2022 · 3 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@nightswimmings
Copy link

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
.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 30, 2022
@wilkinsona wilkinsona self-assigned this May 30, 2022
@wilkinsona wilkinsona changed the title Repository SpyBeans not reseting between tests A @SpyBean on the output of a FactoryBean is not reset May 30, 2022
@wilkinsona
Copy link
Member

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.

@wilkinsona wilkinsona added this to the 2.6.x milestone May 30, 2022
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels May 30, 2022
@wilkinsona wilkinsona modified the milestones: 2.6.x, 2.7.x Nov 24, 2022
anthonydahanne added a commit to anthonydahanne/spring-projects_spring-boot that referenced this issue Mar 8, 2023
* the publishRegistry element has to be configured via a combination of maven command line arguments and maven variables in the pom
@wilkinsona wilkinsona removed their assignment Oct 26, 2023
@wilkinsona wilkinsona modified the milestones: 2.7.x, 3.0.x Oct 26, 2023
@philwebb philwebb modified the milestones: 3.0.x, 3.1.x Nov 8, 2023
@wilkinsona wilkinsona modified the milestones: 3.1.x, 3.2.x Apr 26, 2024
@simonbasle
Copy link

simonbasle commented Aug 13, 2024

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.

@wilkinsona
Copy link
Member

Moved to 3.3.x to avoid potentially destabilising 3.2.x before its final OSS release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants