What i understood is : @Mock creates a mock object which is equivalent to Mockito.mock() Similary @Spy is equivalent to Mockito.spy()
@InjectMocks inject the mock dependecy into a class and created a new object to the class in which mock dependeny are injecting.
I have seen some code where @InjectMocks Class class = Mockito.mock(ClassName.class); or @InjectMocks Class class = Mockito.spy(ClassName.class);
Also what is the difference between Mockito.spy(ClassName.class) and Mockito.spy(new ClassName());
Aucun commentaire:
Enregistrer un commentaire