vendredi 19 février 2021

Can I use the return value from Mockito thenReturn() as an argument on the next Mockito when()?

Can I do something like this:

final var msg = Mockito.when(mapper.map(request)).thenReturn(message);        
final var resp = Mockito.when(messaging.send(msg.getMock())).thenReturn(response);

Instead of msg inside messaging.send() I have Mockito.any(), if I try with msg I am getting a ClassCastException.

Is something like that possible in any way?

Aucun commentaire:

Enregistrer un commentaire