java.lang.Objectmockit.Expectations
public class Expectations
A set of expected method/constructor invocations on one or more mock field instances.
Expectations()protected Expectations()Expectations(Object, boolean) with this instance as the one with the mock fields, and without automatic endRecording.protected Expectations(boolean autoEndRecording)Expectations(Object, boolean) with this instance as the one with the mock fields.protected Expectations(java.lang.Object instanceWithMockFields)Expectations(Object, boolean) without automatic endRecording.protected Expectations(java.lang.Object instanceWithMockFields, boolean autoEndRecording)static void assertSatisfied()endReplay() for the active set of expectations, if any. Expectations endRecording() void endReplay()protected void invoke(java.lang.Class<?> mockClass, java.lang.String methodName, java.lang.Object... methodArgs)protected void invoke(java.lang.Object mock, java.lang.String methodName, java.lang.Object... methodArgs)protected
<T,ET extends T>
voidinvokeReturning(T invocationReturningValue, ET expectedReturnValue)static void restoreFieldTypeDefinitions()protected void returns(java.lang.Object value)protected void setField(java.lang.Class<?> mockClass, java.lang.String fieldName, java.lang.Object fieldValue)protected void setField(java.lang.Object mock, java.lang.String fieldName, java.lang.Object fieldValue)protected void throwsError(java.lang.Error error)protected void throwsException(java.lang.Exception exception)protected
<T> TwithEqual(T arg)equal to the corresponding call argument in the replay phase.protected
<T> TwithInstanceOf(T object)withEqual(Object), but checking that a call argument is an instance of the same class as the given object.clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprotected Expectations()
Expectations(Object, boolean) with this instance as the one with the mock fields, and without automatic endRecording.protected Expectations(boolean autoEndRecording)
Expectations(Object, boolean) with this instance as the one with the mock fields.protected Expectations(java.lang.Object instanceWithMockFields)
Expectations(Object, boolean) without automatic endRecording.
protected Expectations(java.lang.Object instanceWithMockFields,
boolean autoEndRecording)
instanceWithMockFields - the instance which defines the mock fields to be used for this set of expectationsautoEndRecording - indicates whether an automatic endRecording() call should be made at the point of the first replay invocation after the initialization completespublic static void assertSatisfied()
endReplay() for the active set of expectations, if any.public final Expectations endRecording()
public final void endReplay()
restoreFieldTypeDefinitions() in your test tear down.java.lang.IllegalStateException - if there is an active set of expectations which however still is in the recording phasejava.lang.AssertionError - if any expected invocation for the active set of expectations didn't happen until now
protected final void invoke(java.lang.Class<?> mockClass,
java.lang.String methodName,
java.lang.Object... methodArgs)
mockClass - the class on which the invocation is to be done; must not be nullmethodName - the name of the expected static methodmethodArgs - zero or more non-null expected parameter values for the invocation; if a null value needs to be passed, the Class object for the parameter type must be passed instead
protected final void invoke(java.lang.Object mock,
java.lang.String methodName,
java.lang.Object... methodArgs)
mock - the mock field instance on which the invocation is to be done; must not be nullmethodName - the name of the expected methodmethodArgs - zero or more non-null expected parameter values for the invocation; if a null value needs to be passed, the Class object for the parameter type must be passed instead
protected final <T,ET extends T> void invokeReturning(T invocationReturningValue,
ET expectedReturnValue)
invocationReturningValue - the value actually returned by an invocation of the desired method; the value itself is ignored, being only used to determine the method's return typeexpectedReturnValue - the value to be returned when the method is replayedjava.lang.IllegalStateException - if not currently recording invocationspublic static void restoreFieldTypeDefinitions()
Mockit.restoreAllOriginalDefinitions().protected final void returns(java.lang.Object value)
value - the value to be returned when the method is replayed; must be compatible with the method's return typejava.lang.IllegalStateException - if not currently recording invocations
protected final void setField(java.lang.Class<?> mockClass,
java.lang.String fieldName,
java.lang.Object fieldValue)
mockClass - the class on which the static field is definedfieldName - the name of the field to setfieldValue - the value to set the field to
protected final void setField(java.lang.Object mock,
java.lang.String fieldName,
java.lang.Object fieldValue)
mock - the instance on which to set the field valuefieldName - the name of the field to setfieldValue - the value to set the field toprotected final void throwsError(java.lang.Error error)
error - the error that will be thrown when the invocation is replayedjava.lang.IllegalStateException - if not currently recording invocationsprotected final void throwsException(java.lang.Exception exception)
exception - the exception that will be thrown when the invocation is replayedjava.lang.IllegalStateException - if not currently recording invocationsprotected final <T> T with(org.hamcrest.Matcher<T> argumentMatcher)
protected final <T> T withAny(T arg)
protected final <T> T withEqual(T arg)
equal to the corresponding call argument in the replay phase. The matcher is added to the end of the list of argument matchers for the expectation being recorded.arg - the expected argument valueprotected final <T> T withInstanceOf(T object)
withEqual(Object), but checking that a call argument is an instance of the same class as the given object.protected final <T extends java.lang.CharSequence> T withMatch(T regex)
protected final <T> T withNotEqual(T arg)
protected final <T> T withNotNull()
protected final <T> T withNull()
protected final <T extends java.lang.CharSequence> T withPrefix(T text)
protected final <T> T withSameInstance(T object)
protected final <T extends java.lang.CharSequence> T withSubstring(T text)
protected final <T extends java.lang.CharSequence> T withSuffix(T text)
You are viewing a mobilized version of this site...
View original page here