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

In SpringBoot 3.3 @SpyBean can able to mock and spy but after upgrading to Springboot 3.4 @MockitoSpyBean can able to spy but cannot able to mock #44480

Closed
JavaDevaraj opened this issue Feb 28, 2025 · 1 comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue

Comments

@JavaDevaraj
Copy link

In springboot 3.3

@SpyBean
private ReprocessBackOffImpl reprocessBackOffImpl;
doThrow(exception).when(reprocessBackOffImpl).assertPreConditions(context);

Its working fine....

but after upgrading to Springboot 3.4

@MockitoSpyBean
private ReprocessBackOffImpl reprocessBackOffImpl;

doThrow(exception).when(reprocessBackOffImpl).assertPreConditions(context);

getting below exception

Argument passed to when() is not a mock! 
Example of correct stubbing: 
doThrow(new RuntimeException()).when(mock).someMethod(); 
org.mockito.exceptions.misusing.NotAMockException:  Argument passed to when() is not a mock! 
@JavaDevaraj JavaDevaraj changed the title In SpringBoot 3.3 @SpyBean can able to mock and spy but @MockitoSpyBean can able to spy but cannot able to mock In SpringBoot 3.3 @SpyBean can able to mock and spy but after upgrading to Springboot 3.4 @MockitoSpyBean can able to spy but cannot able to mock Feb 28, 2025
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 28, 2025
@bclozel
Copy link
Member

bclozel commented Feb 28, 2025

Duplicates spring-projects/spring-framework#34516
Please avoid cross-posting and wasting contributor's time.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2025
@bclozel bclozel added status: duplicate A duplicate of another issue for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants