public interface IMocksControl
Modifier and Type | Method and Description |
---|---|
void |
checkIsUsedInOneThread(boolean shouldBeUsedInOneThread)
Check that the mock is called from only one thread
|
void |
checkOrder(boolean state)
Switches order checking on and off.
|
<T,R> R |
createMock(Class<T> toMock)
Same as
mock(Class) but using the old naming. |
<T,R> R |
createMock(String name,
Class<T> toMock)
Same as
mock(String, Class) but using the old naming. |
<T,R> R |
createMock(String name,
Class<T> toMock,
ConstructorArgs constructorArgs,
Method... mockedMethods)
Same as
mock(String, Class, ConstructorArgs, Method...) but using the old naming |
void |
makeThreadSafe(boolean threadSafe)
Makes the mock thread safe.
|
default <T,R> R |
mock(Class<T> toMock)
Creates a mock object that implements the given interface.
|
default <T,R> R |
mock(String name,
Class<T> toMock)
Creates a mock object that implements the given interface.
|
default <T,R> R |
mock(String name,
Class<T> toMock,
ConstructorArgs constructorArgs,
Method... mockedMethods)
Creates a mock object that implements the given class.
|
void |
replay()
Switches the control from record mode to replay mode.
|
void |
reset()
Removes all expectations for the mock objects of this control.
|
void |
resetToDefault()
Removes all expectations for the mock objects of this control and turn
them to default mocks.
|
void |
resetToNice()
Removes all expectations for the mock objects of this control and turn
them to nice mocks.
|
void |
resetToStrict()
Removes all expectations for the mock objects of this control and turn
them to strict mocks.
|
void |
verify()
Verifies that all expectations were met and that no unexpected
call was performed.
|
void |
verifyRecording()
Verifies that all expectations were met.
|
void |
verifyUnexpectedCalls()
Verifies that no unexpected call was performed.
|
default <T,R> R mock(Class<T> toMock)
T
- the interface or class that the mock object should
implement/extend.R
- 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 typetoMock
- the interface or class that the mock object should
implement/extend.default <T,R> R mock(String name, Class<T> toMock)
T
- the interface or class that the mock object should
implement/extend.R
- 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 typename
- the name of the mock object.toMock
- the interface or class that the mock object should
implement/extend.IllegalArgumentException
- if the name is not a valid Java identifier.default <T,R> R mock(String name, Class<T> toMock, ConstructorArgs constructorArgs, Method... mockedMethods)
EasyMock.partialMockBuilder(Class)
method insteadT
- the class that the mock object should extend.R
- 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 typename
- the name of the mock object.toMock
- the class that the mock object should extend.constructorArgs
- constructor and parameters used to instantiate the mock. If null, no constructor will be calledmockedMethods
- methods that will be mocked, other methods will behave
normally. If empty, all methods will be mocked<T,R> R createMock(Class<T> toMock)
mock(Class)
but using the old naming.T
- the interface or class that the mock object should
implement/extend.R
- 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 typetoMock
- the interface or class that the mock object should
implement/extend.<T,R> R createMock(String name, Class<T> toMock)
mock(String, Class)
but using the old naming.T
- the interface or class that the mock object should
implement/extend.R
- 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 typename
- the name of the mock object.toMock
- the interface or class that the mock object should
implement/extend.IllegalArgumentException
- if the name is not a valid Java identifier.<T,R> R createMock(String name, Class<T> toMock, ConstructorArgs constructorArgs, Method... mockedMethods)
mock(String, Class, ConstructorArgs, Method...)
but using the old namingT
- the class that the mock object should extend.R
- 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 typename
- the name of the mock object.toMock
- the class that the mock object should extend.constructorArgs
- constructor and parameters used to instantiate the mock. If null, no constructor will be calledmockedMethods
- methods that will be mocked, other methods will behave
normally. If empty, all methods will be mockedvoid reset()
void resetToNice()
void resetToDefault()
void resetToStrict()
void replay()
void verify()
verifyRecording()
followed by verifyUnexpectedCalls()
.void verifyRecording()
void verifyUnexpectedCalls()
void checkOrder(boolean state)
state
- true
switches order checking on,
false
switches it off.void makeThreadSafe(boolean threadSafe)
threadSafe
- If the mock should be thread safe or notvoid checkIsUsedInOneThread(boolean shouldBeUsedInOneThread)
shouldBeUsedInOneThread
- If it should be used in one thread only or notCopyright © 2001–2022 EasyMock contributors. All rights reserved.