Skip to content

@MockBean for a @FeignClient not working as it did in 2.2.5 #21565

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

Closed
N4zroth opened this issue May 25, 2020 · 2 comments
Closed

@MockBean for a @FeignClient not working as it did in 2.2.5 #21565

N4zroth opened this issue May 25, 2020 · 2 comments
Labels
status: duplicate A duplicate of another issue

Comments

@N4zroth
Copy link

N4zroth commented May 25, 2020

I upgraded from 2.2.5 to 2.3.0. We have a @SpringBootTest that uses @MockBean on a @FeignClient. With 2.2.5, we were able to Mockito.when(...) to make the FeignClient return what we wanted in that specific test. After upgrading to 2.3.0, the @MockBean doesn't seem to work correctly: In debug mode I can see that in the test, we indeed have a Mockito mock for the client, in the tested code however it's not a mock but Spring's proxy thus crashing the test. The behaviour can be seen here https://github.com/N4zroth/spring-boot-feign-mockbean , the test fails with 2.3.0 but succeeds with 2.2.5.
I'm quite sure that the previous behavior was correct and the new one is wrong. Correct me if I'm wrong, though.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 25, 2020
@snicoll
Copy link
Member

snicoll commented May 25, 2020

Thanks for the report and the sample. This is a duplicate of #21379

@snicoll snicoll closed this as completed May 25, 2020
@snicoll snicoll added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels May 25, 2020
@N4zroth
Copy link
Author

N4zroth commented May 25, 2020

Ah sorry somehow that didn't come up on Google. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants