In some cases it may not suffice to know whether more that one methods were called. The calling order of methods is also important. In such case you may use InOrder
class of Mockito
to verify the order of methods.
SomeClass mock1 = Mockito.mock(SomeClass.class);
otherClass mock2 = Mockito.mock(OtherClass.class);
// Do something with mocks
InOrder order = Mockito.inOrder(mock1, mock2)
order.verify(mock2).firstMethod();
order.verify(mock1).otherMethod(withParam);
order.verify(mock2).secondMethod(withParam1, withParam2);
The InOrder.verify()
works same as Mockito.verify()
all other aspects.