|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.unitils.easymock.EasyMockUnitils
public class EasyMockUnitils
Utility facade for handling EasyMock things such as replay or manually creating a mock.
Constructor Summary | |
---|---|
EasyMockUnitils()
|
Method Summary | ||
---|---|---|
static
|
createMock(Class<T> mockType)
Creates a lenient mock object of the given type. |
|
static
|
createMock(Class<T> mockType,
InvocationOrder invocationOrder,
Calls calls,
Order order,
Dates dates,
Defaults defaults)
Creates a lenient mock object of the given type. |
|
static
|
createRegularMock(Class<T> mockType)
Creates a regular EasyMock mock object of the given type. |
|
static
|
createRegularMock(Class<T> mockType,
InvocationOrder invocationOrder,
Calls calls)
Creates a regular EasyMock mock object of the given type. |
|
static
|
lenEq(T object)
Expects the given object argument but uses a reflection argument matcher to compare the given value with the actual value during the test. |
|
static
|
refEq(T object,
ReflectionComparatorMode... modes)
Expects the given object argument but uses a reflection argument matcher with the given comparator modes to compare the given value with the actual value during the test. |
|
static void |
replay()
Unit tests should call this method after having set their recorded expected behavior on the mock objects. |
|
static void |
reset()
|
|
static void |
verify()
Unit tests can call this method to check whether all recorded expected behavior was actually observed during the test. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EasyMockUnitils()
Method Detail |
---|
public static <T> T lenEq(T object)
T
- The type of the object to compare withobject
- the value
public static <T> T refEq(T object, ReflectionComparatorMode... modes)
T
- the type of the object to compare withobject
- the valuemodes
- the comparator modes
public static <T> T createRegularMock(Class<T> mockType)
createRegularMock(Class, InvocationOrder, Calls)
with a default invocation order
and default calls value. These defaults can be set in the unitils configuration.
An instance of the mock control is stored, so that it can be set to the replay/verify state when
replay()
or verify()
is called.
T
- the type of the mockmockType
- the type of the mock, not null
public static <T> T createRegularMock(Class<T> mockType, InvocationOrder invocationOrder, Calls calls)
replay()
or verify()
is called.
T
- the type of the mockmockType
- the class type for the mock, not nullinvocationOrder
- the order setting, not nullcalls
- the calls setting, not null
public static <T> T createMock(Class<T> mockType)
LenientMocksControl
is used
for creating the mock.
Same as createMock(Class, InvocationOrder, Calls, Order, Dates, Defaults)
with a default invocation order,
default calls, default order, default dates and default defaults value. These defaults can be set in the
unitils configuration.
An instance of the mock control is stored, so that it can be set to the replay/verify state when
replay()
or verify()
is called.
T
- the type of the mockmockType
- the type of the mock, not null
public static <T> T createMock(Class<T> mockType, InvocationOrder invocationOrder, Calls calls, Order order, Dates dates, Defaults defaults)
LenientMocksControl
is used
for creating the mock.
Same as createMock(Class, InvocationOrder, Calls, Order, Dates, Defaults)
with a default invocation order,
default calls, default order, default dates and default defaults value. These defaults can be set in the
unitils configuration.
An instance of the mock control is stored, so that it can be set to the replay/verify state when
replay()
or verify()
is called.
T
- the type of the mockmockType
- the type of the mock, not nullinvocationOrder
- the invocation order setting, not nullcalls
- the calls setting, not nullorder
- the order setting, not nulldates
- the dates setting, not nulldefaults
- the defaults setting, not null
public static void replay()
Mock
, or directly created by the
createRegularMock(Class, InvocationOrder, Calls)
and
createMock(Class, InvocationOrder, Calls, Order, Dates, Defaults)
methods.
After each test, the expected behavior is verified automatically, or explicitly by calling verify()
.
public static void reset()
public static void verify()
MocksControl.verify()
method is called for every mock mock object
that was injected to a field annotated with Mock
, or directly created by the
createRegularMock(Class, InvocationOrder, Calls)
or
createMock(Class, InvocationOrder, Calls, Order, Dates, Defaults)
methods.
By default, the expected behavior is verified automatically. This can be disabled however by setting the property
EasyMockModule.autoVerifyAfterTest.enabled to false. In that case, verification can also be performed explicitly
by calling this method.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |