public class EasyMockModule extends Object implements Module
Mock annotation.
All methods annotated with AfterCreateMock will be called when a mock object was created. This provides
you with a hook method for custom handling of the mock (e.g. adding the mocks to a service locator repository).
A method can only be called if it has following signature void myMethod(Object mock, String name, Class type).
Mocks can also be created explicitly
todo javadoc
Switching to the replay state and verifying expectations of all mocks (including the mocks created with
the createMock() method can be done by calling
the replay() and verify() methods.| Modifier and Type | Class and Description |
|---|---|
protected class |
EasyMockModule.EasyMockTestListener
Test listener that handles the mock creation and injection.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
PROPKEY_AUTO_VERIFY_AFTER_TEST_ENABLED |
| Constructor and Description |
|---|
EasyMockModule() |
| Modifier and Type | Method and Description |
|---|---|
void |
addMocksControlToList(org.easymock.internal.MocksControl control) |
void |
afterInit()
No after initialization needed for this module
|
protected void |
callAfterCreateMockMethods(Object testObject,
Object mockObject,
String name,
Class<?> type)
Calls all
AfterCreateMock annotated methods on the test, passing the given mock. |
protected void |
createAndInjectMocksIntoTest(Object testObject) |
protected void |
createAndInjectRegularMocksIntoTest(Object testObject)
Creates and sets a mock for all
RegularMock annotated fields. |
<T> T |
createMock(Class<T> mockType,
InvocationOrder invocationOrder,
Calls calls,
Order order,
Dates dates,
Defaults defaults)
todo javadoc
Creates an EasyMock mock instance of the given type (class/interface).
|
<T> T |
createRegularMock(Class<T> mockType,
InvocationOrder invocationOrder,
Calls calls)
Creates an EasyMock mock object of the given type.
|
TestListener |
getTestListener()
Creates the listener for plugging in the behavior of this module into the test runs.
|
void |
init(Properties configuration)
Initializes the module
|
void |
replay()
Replays all mock controls.
|
void |
reset()
Resets all mock controls.
|
void |
verify()
This method makes sure
MocksControl.verify() method is called for every mock mock object
that was injected to a field annotated with Mock, or directly created by calling
createRegularMock(Class, InvocationOrder, Calls) or
createMock(Class, InvocationOrder, Calls, Order, Dates, Defaults). |
public static final String PROPKEY_AUTO_VERIFY_AFTER_TEST_ENABLED
public void init(Properties configuration)
public void afterInit()
public TestListener getTestListener()
getTestListener in interface Modulepublic <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 nullpublic <T> T createMock(Class<T> mockType, InvocationOrder invocationOrder, Calls calls, Order order, Dates dates, Defaults defaults)
T - the type of the mockmockType - the type of the mock, not nullinvocationOrder - the order setting, not nullcalls - the calls setting, not nullorder - tododates - tododefaults - todopublic void replay()
public void reset()
public 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 calling
createRegularMock(Class, InvocationOrder, Calls) or
createMock(Class, InvocationOrder, Calls, Order, Dates, Defaults).
If there are mocks that weren't already switched to the replay state using MocksControl.replay()} or by
calling EasyMockUnitils.replay(), this method is called first.protected void createAndInjectRegularMocksIntoTest(Object testObject)
RegularMock annotated fields.
The
todo javadoc
method is called for creating the mocks. Ones the mock is created, all methods annotated with AfterCreateMock will be called passing the created mock.testObject - the test, not nullprotected void createAndInjectMocksIntoTest(Object testObject)
protected void callAfterCreateMockMethods(Object testObject, Object mockObject, String name, Class<?> type)
AfterCreateMock annotated methods on the test, passing the given mock.
These annotated methods must have following signature void myMethod(Object mock, String name, Class type).
If this is not the case, a runtime exception is called.testObject - the test, not nullmockObject - the mock, not nullname - the field(=mock) name, not nulltype - the field(=mock) typepublic void addMocksControlToList(org.easymock.internal.MocksControl control)
Copyright © 2017. All rights reserved.