|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.unitils.mock.MockModule
public class MockModule
Module for testing with mock objects.
Nested Class Summary | |
---|---|
protected class |
MockModule.MockTestListener
Test listener that handles the scenario and mock creation, and makes sure a final syntax check is performed after each test and that scenario reports are logged if required. |
Constructor Summary | |
---|---|
MockModule()
|
Method Summary | ||
---|---|---|
void |
afterInit()
Gives the module the opportunity to performs initialization that can only work after all other modules have been initialized |
|
protected void |
callAfterCreateMockMethods(Object testObject,
Mock<?> mockObject,
String name)
Calls all AfterCreateMock annotated methods on the test, passing the given mock. |
|
protected void |
createAndInjectDummiesIntoTest(Object testObject)
checks for the Dummy annotation on the testObject. |
|
protected void |
createAndInjectMocksIntoTest(Object testObject)
|
|
protected void |
createAndInjectPartialMocksIntoTest(Object testObject)
|
|
protected
|
createMock(Object testObject,
String name,
Class<?> type)
|
|
protected
|
createPartialMock(Object testObject,
String name,
Class<?> type)
|
|
protected Class<?> |
getMockedClass(Field field)
|
|
TestListener |
getTestListener()
Creates the listener for plugging in the behavior of this module into the test runs. |
|
void |
init(Properties configuration)
Initializes the module with the given configuration settings. |
|
protected void |
injectMock(Object testObject,
Field field,
Mock<?> mock)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MockModule()
Method Detail |
---|
public void init(Properties configuration)
Module
init
in interface Module
configuration
- The config, not nullpublic void afterInit()
Module
afterInit
in interface Module
protected void createAndInjectMocksIntoTest(Object testObject)
protected void createAndInjectPartialMocksIntoTest(Object testObject)
protected <T> Mock<T> createMock(Object testObject, String name, Class<?> type)
protected <T> Mock<T> createPartialMock(Object testObject, String name, Class<?> type)
protected Class<?> getMockedClass(Field field)
protected void injectMock(Object testObject, Field field, Mock<?> mock)
protected void createAndInjectDummiesIntoTest(Object testObject)
Dummy
annotation on the testObject. If so it is created by the DummyObjectUtil. The two aproaches possible are
stuffed or normal depending on the value in the Dummy
annotation.
testObject
- The tested object not nullprotected void callAfterCreateMockMethods(Object testObject, Mock<?> mockObject, String name)
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 nullpublic TestListener getTestListener()
getTestListener
in interface Module
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |