mockit.FullVerificationsInOrder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmockit Show documentation
Show all versions of jmockit Show documentation
JMockit is a Java toolkit for developer (unit/integration) testing.
It contains mocking APIs and other tools, supporting both JUnit and TestNG.
The mocking APIs allow all kinds of Java code, without testability restrictions, to be tested
in isolation from selected dependencies.
/*
* Copyright (c) 2006-2011 Rogério Liesenfeld
* This file is subject to the terms of the MIT license (see LICENSE.txt).
*/
package mockit;
/**
* A combination of {@link FullVerifications} and {@link VerificationsInOrder}.
*
* Note that the behavior provided by this class is essentially the same obtained through an strict
* {@link Expectations} recording block, except that the number of expected invocations for each
* expectation is still "non-strict".
*
* In the Tutorial
*/
public abstract class FullVerificationsInOrder extends Verifications
{
/**
* Begins in-order verification for all invocations on the mocked types/instances that can
* potentially be invoked during the replay phase.
*/
protected FullVerificationsInOrder()
{
super(true);
verificationPhase.setAllInvocationsMustBeVerified();
}
/**
* Begins in-order verification for all mocked types/instances invoked during the replay phase of
* the test, considering that such invocations occurred in a given number of iterations.
*
* The effect of specifying a number of iterations larger than 1 (one) is equivalent to duplicating (like in "copy &
* paste") the whole sequence of invocations in the block.
*
* @param numberOfIterations the positive number of iterations for the whole set of invocations verified inside the
* block; when not specified, 1 (one) iteration is assumed
*/
protected FullVerificationsInOrder(int numberOfIterations)
{
super(true);
verificationPhase.setAllInvocationsMustBeVerified();
verificationPhase.setNumberOfIterations(numberOfIterations);
}
/**
* Same as {@link #FullVerificationsInOrder()}, but restricting the verification to the specified mocked types and/or
* mocked instances.
*
* @param mockedTypesAndInstancesToVerify one or more of the mocked types (ie, {@code Class} objects) and/or mocked
* instances that are in scope for the test; for a given mocked instance, all classes up to (but not
* including) {@code java.lang.Object} are considered
*/
protected FullVerificationsInOrder(Object... mockedTypesAndInstancesToVerify)
{
this();
verificationPhase.setMockedTypesToFullyVerify(mockedTypesAndInstancesToVerify);
}
/**
* Same as {@link #FullVerificationsInOrder(int)}, but restricting the verification to the specified mocked types
* and/or mocked instances.
*
* @param mockedTypesAndInstancesToVerify one or more of the mocked types (ie, {@code Class} objects) and/or mocked
* instances that are in scope for the test; for a given mocked instance, all classes up to (but not
* including) {@code java.lang.Object} are considered
*/
protected FullVerificationsInOrder(int numberOfIterations, Object... mockedTypesAndInstancesToVerify)
{
this(numberOfIterations);
verificationPhase.setMockedTypesToFullyVerify(mockedTypesAndInstancesToVerify);
}
}