org.mockito.InOrder Maven / Gradle / Ivy
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito;
import org.mockito.internal.verification.api.VerificationMode;
/**
* Allows verification in order. E.g:
*
*
* InOrder inOrder = inOrder(firstMock, secondMock);
*
* inOrder.verify(firstMock).add("was called first");
* inOrder.verify(secondMock).add("was called second");
*
*
* See examples in javadoc for {@link Mockito} class
*/
public interface InOrder {
/**
* Verifies interaction happened once in order.
*
* 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 {@link Mockito} class
*
* @param mock to be verified
*
* @return mock object itself
*/
T verify(T mock);
/**
* Verifies interaction in order. E.g:
*
*
* 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 {@link Mockito} class
*
* @param mock to be verified
* @param mode for example times(x) or atLeastOnce()
*
* @return mock object itself
*/
T verify(T mock, VerificationMode mode);
}