jeudi 4 juin 2015

what's the point using Mockito to mock objects? [duplicate]

This is a mockito example from mockito website: It mocks a List object and test it. What's the point doing this? what's the benefits from this? Why can't i just instantiated a list?

 //Let's import Mockito statically so that the code looks clearer
 import static org.mockito.Mockito.*;

 //mock creation
 List mockedList = mock(List.class);

 //using mock object
 mockedList.add("one");
 mockedList.clear();

 //verification
 verify(mockedList).add("one");
 verify(mockedList).clear();

Aucun commentaire:

Enregistrer un commentaire