public class InOrderImpl extends Object implements InOrder, InOrderContext
Constructor and Description |
---|
InOrderImpl(List<Object> mocksToBeVerifiedInOrder) |
Modifier and Type | Method and Description |
---|---|
List<Object> |
getMocksToBeVerifiedInOrder() |
boolean |
isVerified(Invocation i) |
void |
markVerified(Invocation i) |
<T> T |
verify(T mock)
Verifies interaction happened once in order.
|
<T> T |
verify(T mock,
VerificationMode mode)
Verifies interaction in order.
|
void |
verifyNoMoreInteractions()
Verifies that no more interactions happened in order.
|
public <T> T verify(T mock)
InOrder
Alias to inOrder.verify(mock, times(1))
Example:
InOrder inOrder = inOrder(firstMock, secondMock);
inOrder.verify(firstMock).someMethod("was called first");
inOrder.verify(secondMock).someMethod("was called second");
See examples in javadoc for Mockito
classpublic <T> T verify(T mock, VerificationMode mode)
InOrder
InOrder inOrder = inOrder(firstMock, secondMock);
inOrder.verify(firstMock, times(2)).someMethod("was called first two times");
inOrder.verify(secondMock, atLeastOnce()).someMethod("was called second at least once");
See examples in javadoc for Mockito
classpublic boolean isVerified(Invocation i)
isVerified
in interface InOrderContext
public void markVerified(Invocation i)
markVerified
in interface InOrderContext
public void verifyNoMoreInteractions()
InOrder
Mockito.verifyNoMoreInteractions(Object...)
because the order of verification matters.
Example:
mock.foo(); //1st
mock.bar(); //2nd
mock.baz(); //3rd
InOrder inOrder = inOrder(mock);
inOrder.verify(mock).bar(); //2n
inOrder.verify(mock).baz(); //3rd (last method)
//passes because there are no more interactions after last method:
inOrder.verifyNoMoreInteractions();
//however this fails because 1st method was not verified:
Mockito.verifyNoMoreInteractions(mock);
verifyNoMoreInteractions
in interface InOrder