T
- type of the mock createdIMockBuilder<T>
public class MockBuilder<T> extends java.lang.Object implements IMockBuilder<T>
The original idea and part of the code where contributed by Rodrigo Damazio and Bruno Fonseca at Google
Constructor | Description |
---|---|
MockBuilder(java.lang.Class<T> toMock) |
|
MockBuilder(java.lang.Class<T> toMock,
EasyMockSupport support) |
Used by EasyMockSupport to allow the mock registration in the list of
controls
|
Modifier and Type | Method | Description |
---|---|---|
IMockBuilder<T> |
addMockedMethod(java.lang.reflect.Method method) |
Adds a method to be mocked in the testing class.
|
IMockBuilder<T> |
addMockedMethod(java.lang.String methodName) |
Adds a method to be mocked in the testing class.
|
IMockBuilder<T> |
addMockedMethod(java.lang.String methodName,
java.lang.Class<?>... parameterTypes) |
Adds a method to be mocked in the testing class.
|
IMockBuilder<T> |
addMockedMethods(java.lang.reflect.Method... methods) |
Adds methods to be mocked in the testing class.
|
IMockBuilder<T> |
addMockedMethods(java.lang.String... methodNames) |
Adds methods to be mocked in the testing class.
|
T |
createMock() |
Create a default mock from this builder.
|
T |
createMock(java.lang.String name) |
Create named mock from the provided mock control using the arguments
passed to the builder.
|
T |
createMock(java.lang.String name,
IMocksControl control) |
Create named mock from the provided mock control using the arguments
passed to the builder.
|
T |
createMock(java.lang.String name,
MockType type) |
Create a named mock of the request type from this builder.
|
T |
createMock(IMocksControl control) |
Create mock from the provided mock control using the arguments passed to
the builder.
|
T |
createMock(MockType type) |
Create mock of the request type from this builder.
|
T |
createNiceMock() |
Create a nice mock from this builder.
|
T |
createNiceMock(java.lang.String name) |
Create a named nice mock from this builder.
|
T |
createStrictMock() |
Create a strict mock from this builder.
|
T |
createStrictMock(java.lang.String name) |
Create a named strict mock from this builder.
|
IMockBuilder<T> |
withArgs(java.lang.Object... initArgs) |
Defines the arguments to be passed to the constructor of the class.
|
IMockBuilder<T> |
withConstructor() |
Defines the empty constructor should be called.
|
IMockBuilder<T> |
withConstructor(java.lang.Class<?>... argTypes) |
Defines the exact argument types for the constructor to use.
|
IMockBuilder<T> |
withConstructor(java.lang.Object... initArgs) |
Defines the constructor parameters for the mocked class.
|
IMockBuilder<T> |
withConstructor(java.lang.reflect.Constructor<?> constructor) |
Defines the constructor to use to instantiate the mock.
|
IMockBuilder<T> |
withConstructor(ConstructorArgs constructorArgs) |
public MockBuilder(java.lang.Class<T> toMock)
public MockBuilder(java.lang.Class<T> toMock, EasyMockSupport support)
toMock
- The class of the mock to createsupport
- The EasyMockSupport used to create mocks. Null if nonepublic IMockBuilder<T> addMockedMethod(java.lang.reflect.Method method)
IMockBuilder
addMockedMethod
in interface IMockBuilder<T>
method
- method to be mockedpublic IMockBuilder<T> addMockedMethod(java.lang.String methodName)
IMockBuilder
addMockedMethod
s in this class if that is the case.addMockedMethod
in interface IMockBuilder<T>
methodName
- name of the method to be mockedpublic IMockBuilder<T> addMockedMethod(java.lang.String methodName, java.lang.Class<?>... parameterTypes)
IMockBuilder
addMockedMethod
in interface IMockBuilder<T>
methodName
- name of the method to be mockedparameterTypes
- types of the parameters of the methodpublic IMockBuilder<T> addMockedMethods(java.lang.String... methodNames)
IMockBuilder
IMockBuilder.addMockedMethod(String)
but to mock many methods at once.addMockedMethods
in interface IMockBuilder<T>
methodNames
- names of the methods to be mockedpublic IMockBuilder<T> addMockedMethods(java.lang.reflect.Method... methods)
IMockBuilder
IMockBuilder.addMockedMethod(Method)
but to mock many methods at once.addMockedMethods
in interface IMockBuilder<T>
methods
- methods to be mockedpublic IMockBuilder<T> withConstructor(java.lang.reflect.Constructor<?> constructor)
IMockBuilder
IMockBuilder.withArgs(java.lang.Object...)
with the actual constructor argument
values after this.withConstructor
in interface IMockBuilder<T>
constructor
- the constructor to be calledpublic IMockBuilder<T> withConstructor(ConstructorArgs constructorArgs)
public IMockBuilder<T> withConstructor()
IMockBuilder
withConstructor
in interface IMockBuilder<T>
public IMockBuilder<T> withConstructor(java.lang.Object... initArgs)
IMockBuilder
withConstructor
in interface IMockBuilder<T>
initArgs
- arguments of the constructorpublic IMockBuilder<T> withConstructor(java.lang.Class<?>... argTypes)
IMockBuilder
IMockBuilder.withArgs(java.lang.Object...)
with the actual constructor
argument values after this.withConstructor
in interface IMockBuilder<T>
argTypes
- the exact argument types of the constructorpublic IMockBuilder<T> withArgs(java.lang.Object... initArgs)
IMockBuilder
IMockBuilder.withConstructor(Class...)
or
IMockBuilder.withConstructor(Constructor)
.withArgs
in interface IMockBuilder<T>
initArgs
- the arguments to pass to the constructorpublic T createMock(MockType type)
IMockBuilder
createMock
in interface IMockBuilder<T>
type
- the mock typepublic T createMock(java.lang.String name, MockType type)
IMockBuilder
createMock
in interface IMockBuilder<T>
name
- the mock nametype
- the mock typepublic T createMock(IMocksControl control)
IMockBuilder
createMock
in interface IMockBuilder<T>
control
- IMocksControl
used to create the objectpublic T createMock()
IMockBuilder
createMock
in interface IMockBuilder<T>
public T createNiceMock()
IMockBuilder
createNiceMock
in interface IMockBuilder<T>
public T createStrictMock()
IMockBuilder
createStrictMock
in interface IMockBuilder<T>
public T createMock(java.lang.String name, IMocksControl control)
IMockBuilder
createMock
in interface IMockBuilder<T>
name
- the mock namecontrol
- IMocksControl
used to create the objectpublic T createMock(java.lang.String name)
IMockBuilder
createMock
in interface IMockBuilder<T>
name
- the mock namepublic T createNiceMock(java.lang.String name)
IMockBuilder
createNiceMock
in interface IMockBuilder<T>
name
- the mock namepublic T createStrictMock(java.lang.String name)
IMockBuilder
createStrictMock
in interface IMockBuilder<T>
name
- the mock nameCopyright © 2001-2019 EasyMock contributors. This documentation is provided under the terms of the Apache 2 licence.