jeudi 28 avril 2016

how to assert mock calls are in some order? [duplicate]

This question already has an answer here:

I want to write a junit test with mockito

say this is my mock:

IServerApi routingServerApi = mock(ServerApi.class);
        when(routingServerApi.sendRequest(anyString(), eq("request1"))).thenReturn(myObj1);
        when(routingServerApi.sendRequest(anyString(), eq("request2"))).thenReturn(myObj2);

I want to verify that sendRequest is called with request1 just before it's called with request2 (and no other invocation between them).

How can i do this?

Aucun commentaire:

Enregistrer un commentaire