Example of usage:
public class SupportTest extends EasyMockSupport {
@Test
public void test() {
firstMock = createMock(A.class);
secondMock = createMock(B.class);
replayAll(); // put both mocks in replay mode
// ... use mocks ..
verifyAll(); // verify both mocks
}
}
| Modifier and Type | Class and Description |
|---|---|
| private static class | EasyMockSupport.
Hides ByteBuddy classes from EasyMockSupport to prevent |
| Modifier and Type | Field and Description |
|---|---|
| protected final List | controls
List of all controls created |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public IMocksControl | |
| public IMocksControl | |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | Returns: the mock object.the type of the mock to be created. type, Class<T> the class of the interface that the mock object should
implement. toMock)Creates a mock object of the requested type that implements the given interface or extends the given class |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | Returns: the mock object.the name of the mock object. name, MockType the type of the mock to be created. type, Class<T> the class of the interface that the mock object should
implement. toMock)Creates a mock object of the requested type that implements the given interface or extends the given class |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | Returns: the mock object.the class of the interface that the mock object should
implement. toMock)Creates a mock object that implements the given interface, order checking is disabled by default. |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | Returns: the mock object.the name of the mock object. name, Class<T> the class of the interface that the mock object should
implement. toMock)Creates a mock object that implements the given interface, order checking is disabled by default. |
| public < the interface that the mock object should implement. T> IMockBuilder | Returns: a mock builder to create a partial mockthe class of the interface that the mock object should
implement. toMock)Create a mock builder allowing to create a partial mock for the given class or interface. |
| public IMocksControl | Returns: the control.Creates a control, order checking is disabled by default, and the mock
objects created by this control will return |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | Returns: the mock object.the class of the interface that the mock object should
implement. toMock)Creates a mock object that implements the given interface, order checking
is disabled by default, and the mock object will return |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | Returns: the mock object.the name of the mock object. name, Class<T> the class of the interface that the mock object should
implement. toMock)Creates a mock object that implements the given interface, order checking
is disabled by default, and the mock object will return |
| public IMocksControl | |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | Returns: the mock object.the class of the interface that the mock object should
implement. toMock)Creates a mock object that implements the given interface, order checking is enabled by default. |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | Returns: the mock object.the name of the mock object. name, Class<T> the class of the interface that the mock object should
implement. toMock)Creates a mock object that implements the given interface, order checking is enabled by default. |
| public static < type of the possible mock T, type of mocked class R extends T> Class | Returns: the mocked type or null of not a mockmock we want the type of possibleMock)Will return the class that was mocked if it's a mock or |
| public static void | injectMocks(Object
the object on which to inject mocks obj)Inject a mock to every fields annotated with |
| public static boolean | |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | Returns: the mock object.the name of the mock object. name, MockType the type of the mock to be created. type, Class<T> the class of the interface that the mock object should
implement. toMock)Creates a mock object of the requested type that implements the given interface or extends the given class |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | Returns: the mock object.the name of the mock object. name, Class<T> the class of the interface that the mock object should
implement. toMock)Creates a mock object that implements the given interface, order checking
is disabled by default, and the mock object will return |
| public < the interface that the mock object should implement. T> IMockBuilder | Returns: a mock builder to create a partial mockthe class of the interface that the mock object should
implement. toMock)Create a mock builder allowing to create a partial mock for the given class or interface. |
| public void | replayAll()
Switches all registered mock objects (more exactly: the controls of the mock objects) to replay mode. |
| public void | |
| public void | resetAllToDefault()
Resets all registered mock objects (more exactly: the controls of the mock objects) and turn them to a mock with default behavior. |
| public void | resetAllToNice()
Resets all registered mock objects (more exactly: the controls of the mock objects) and turn them to a mock with nice behavior. |
| public void | resetAllToStrict()
Resets all registered mock objects (more exactly: the controls of the mock objects) and turn them to a mock with strict behavior. |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | Returns: the mock object.the class of the interface that the mock object should
implement. toMock)Creates a mock object that implements the given interface, order checking is enabled by default. |
| public < the interface that the mock object should implement. T, the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
caller, we return a different type R> R | Returns: the mock object.the name of the mock object. name, Class<T> the class of the interface that the mock object should
implement. toMock)Creates a mock object that implements the given interface, order checking is enabled by default. |
| public void | verifyAll()
Verifies all registered mock objects have their expectations met and that no unexpected call was performed. |
| public void | |
| public void |
| controls | back to summary |
|---|---|
| protected final List<IMocksControl> controls List of all controls created | |
| EasyMockSupport | back to summary |
|---|---|
| public EasyMockSupport() | |
| createControl | back to summary |
|---|---|
| public IMocksControl createControl(MockType type) Creates a control of the given type.
| |
| createControl | back to summary |
|---|---|
| public IMocksControl createControl() Creates a control, order checking is disabled by default.
| |
| createMock | back to summary |
|---|---|
| public <T, R> R createMock(MockType type, Class<T> toMock) Creates a mock object of the requested type that implements the given interface or extends the given class
| |
| createMock | back to summary |
|---|---|
| public <T, R> R createMock(String name, MockType type, Class<T> toMock) Creates a mock object of the requested type that implements the given interface or extends the given class
| |
| createMock | back to summary |
|---|---|
| public <T, R> R createMock(Class<T> toMock) Creates a mock object that implements the given interface, order checking is disabled by default.
| |
| createMock | back to summary |
|---|---|
| public <T, R> R createMock(String name, Class<T> toMock) Creates a mock object that implements the given interface, order checking is disabled by default.
| |
| createMockBuilder | back to summary |
|---|---|
| public <T> IMockBuilder Create a mock builder allowing to create a partial mock for the given class or interface.
| |
| createNiceControl | back to summary |
|---|---|
| public IMocksControl createNiceControl() Creates a control, order checking is disabled by default, and the mock
objects created by this control will return
| |
| createNiceMock | back to summary |
|---|---|
| public <T, R> R createNiceMock(Class<T> toMock) Creates a mock object that implements the given interface, order checking
is disabled by default, and the mock object will return
| |
| createNiceMock | back to summary |
|---|---|
| public <T, R> R createNiceMock(String name, Class<T> toMock) Creates a mock object that implements the given interface, order checking
is disabled by default, and the mock object will return
| |
| createStrictControl | back to summary |
|---|---|
| public IMocksControl createStrictControl() Creates a control, order checking is enabled by default.
| |
| createStrictMock | back to summary |
|---|---|
| public <T, R> R createStrictMock(Class<T> toMock) Creates a mock object that implements the given interface, order checking is enabled by default.
| |
| createStrictMock | back to summary |
|---|---|
| public <T, R> R createStrictMock(String name, Class<T> toMock) Creates a mock object that implements the given interface, order checking is enabled by default.
| |
| getMockedClass | back to summary |
|---|---|
| public static <T, R extends T> Class Will return the class that was mocked if it's a mock or
| |
| injectMocks | back to summary |
|---|---|
| public static void injectMocks(Object obj) Inject a mock to every fields annotated with The rules are
Note If the parameter extends
| |
| isAMock | back to summary |
|---|---|
| public static boolean isAMock(Object possibleMock) Tells if this mock is an EasyMock mock.
| |
| mock | back to summary |
|---|---|
| public <T, R> R mock(Class<T> toMock) Creates a mock object that implements the given interface, order checking is disabled by default.
| |
| mock | back to summary |
|---|---|
| public <T, R> R mock(String name, Class<T> toMock) Creates a mock object that implements the given interface, order checking is disabled by default.
| |
| mock | back to summary |
|---|---|
| public <T, R> R mock(MockType type, Class<T> toMock) Creates a mock object of the requested type that implements the given interface or extends the given class
| |
| mock | back to summary |
|---|---|
| public <T, R> R mock(String name, MockType type, Class<T> toMock) Creates a mock object of the requested type that implements the given interface or extends the given class
| |
| niceMock | back to summary |
|---|---|
| public <T, R> R niceMock(Class<T> toMock) Creates a mock object that implements the given interface, order checking
is disabled by default, and the mock object will return
| |
| niceMock | back to summary |
|---|---|
| public <T, R> R niceMock(String name, Class<T> toMock) Creates a mock object that implements the given interface, order checking
is disabled by default, and the mock object will return
| |
| partialMockBuilder | back to summary |
|---|---|
| public <T> IMockBuilder Create a mock builder allowing to create a partial mock for the given class or interface.
| |
| replayAll | back to summary |
|---|---|
| public void replayAll() Switches all registered mock objects (more exactly: the controls of the mock objects) to replay mode. For details, see the EasyMock documentation. | |
| resetAll | back to summary |
|---|---|
| public void resetAll() Resets all registered mock objects (more exactly: the controls of the mock objects). For details, see the EasyMock documentation. | |
| resetAllToDefault | back to summary |
|---|---|
| public void resetAllToDefault() Resets all registered mock objects (more exactly: the controls of the mock objects) and turn them to a mock with default behavior. For details, see the EasyMock documentation. | |
| resetAllToNice | back to summary |
|---|---|
| public void resetAllToNice() Resets all registered mock objects (more exactly: the controls of the mock objects) and turn them to a mock with nice behavior. For details, see the EasyMock documentation. | |
| resetAllToStrict | back to summary |
|---|---|
| public void resetAllToStrict() Resets all registered mock objects (more exactly: the controls of the mock objects) and turn them to a mock with strict behavior. For details, see the EasyMock documentation. | |
| strictMock | back to summary |
|---|---|
| public <T, R> R strictMock(Class<T> toMock) Creates a mock object that implements the given interface, order checking is enabled by default.
| |
| strictMock | back to summary |
|---|---|
| public <T, R> R strictMock(String name, Class<T> toMock) Creates a mock object that implements the given interface, order checking is enabled by default.
| |
| verifyAll | back to summary |
|---|---|
| public void verifyAll() Verifies all registered mock objects have their expectations met and that no unexpected call was performed.
This method as same effect as calling | |
| verifyAllRecordings | back to summary |
|---|---|
| public void verifyAllRecordings() Verifies all registered mock objects have their expectations met.
| |
| verifyAllUnexpectedCalls | back to summary |
|---|---|
| public void verifyAllUnexpectedCalls() Verifies that no registered mock objects had unexpected calls.
| |
NoClassDefFoundError if
ByteBuddy isn't used.
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static boolean |
| ObjectMockingHelper | back to summary |
|---|---|
| private ObjectMockingHelper() | |
| isAClassMock | back to summary |
|---|---|
| public static boolean isAClassMock(Object possibleMock) | |