jeudi 13 février 2020

Is there a way in Mockito to return the object if it was received?

Is there a way to return the received object in Mockito? I want to do this simulating the saving of the object in the database. Something like this:

someClass someObj = ...;

when(dataProviderMock.insert(someObj))
    .then(
          when(dataProviderMock.read(someObj.getId()))
         .thenReturn(someObj)
    );

Aucun commentaire:

Enregistrer un commentaire