Difference between @Mock, @MockBean and Mockito.mock()

When creating tests and mocking dependencies, what is the difference between these three approaches?

  1. @MockBean:

    @MockBean
    MyService myservice;
    
  2. @Mock:

    @Mock
    MyService myservice;
    
  3. Mockito.mock()

    MyService myservice = Mockito.mock(MyService.class);
    

2 Answers
2

Leave a Comment