What is difference between @SpyBean and @MockBean in Mockito?

Viewed 51148

What is the difference between the @SpyBean and @MockBean annotations in Spring?

I have already gone through the JavaDoc but didn't get the difference. If possible please give an example when to use MockBean and when SpyBean.

2 Answers

really important to note that the two annotations you are referencing come from Spring Boot, not Mockito (even though that spring lib theyre from is based on Mockito)

mixing test frameworks can give confusing and inaccurate results.

Related