@Beta public class DetachedMockFactory extends java.lang.Object implements MockFactory
Specification,
e.g., in a Spring configuration.
In order to be usable those Mocks must be manually attached to the Specification
using MockUtil.attachMock(Object, Specification) and detached afterwards MockUtil.detachMock(Object).| Constructor and Description |
|---|
DetachedMockFactory() |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
createMock(java.lang.String name,
java.lang.Class<T> type,
org.spockframework.mock.MockNature nature,
java.util.Map<java.lang.String,java.lang.Object> options) |
<T> T |
createMock(java.lang.String name,
T obj,
org.spockframework.mock.MockNature nature,
java.util.Map<java.lang.String,java.lang.Object> options) |
<T> T |
Mock(java.lang.Class<T> type)
Creates a mock with the specified type.
|
<T> T |
Mock(java.util.Map<java.lang.String,java.lang.Object> options,
java.lang.Class<T> type)
Creates a mock with the specified options and type.
|
<T> T |
Spy(java.lang.Class<T> type)
Creates a spy with the specified type.
|
<T> T |
Spy(java.util.Map<java.lang.String,java.lang.Object> options,
java.lang.Class<T> type)
Creates a spy with the specified options and type.
|
<T> T |
Spy(T obj)
Creates a spy wrapping a provided instance.
|
<T> T |
Stub(java.lang.Class<T> type)
Creates a stub with the specified type.
|
<T> T |
Stub(java.util.Map<java.lang.String,java.lang.Object> options,
java.lang.Class<T> type)
Creates a stub with the specified options and type.
|
public <T> T Mock(java.lang.Class<T> type)
def person = Mock(Person) // type is Person.class, name is "person"
Mock in interface MockFactoryT - the interface or class type of the mocktype - the interface or class type of the mockpublic <T> T Mock(java.util.Map<java.lang.String,java.lang.Object> options,
java.lang.Class<T> type)
def person = Mock(Person, name: "myPerson") // type is Person.class, name is "myPerson"
Mock in interface MockFactoryT - the interface or class type of the mockoptions - optional options for creating the mocktype - the interface or class type of the mockpublic <T> T Stub(java.lang.Class<T> type)
def person = Stub(Person) // type is Person.class, name is "person"
Stub in interface MockFactoryT - the interface or class type of the stubtype - the interface or class type of the stubpublic <T> T Stub(java.util.Map<java.lang.String,java.lang.Object> options,
java.lang.Class<T> type)
def person = Stub(Person, name: "myPerson") // type is Person.class, name is "myPerson"
Stub in interface MockFactoryT - the interface or class type of the stuboptions - optional options for creating the stubtype - the interface or class type of the stubpublic <T> T Spy(java.lang.Class<T> type)
def person = Spy(Person) // type is Person.class, name is "person"
Spy in interface MockFactoryT - the class type of the spytype - the class type of the spypublic <T> T Spy(T obj)
MockFactorydef person = Spy(new Person()) // type is Person.class, name is "person"
Spy in interface MockFactoryT - the class type of the spyobj - the instance to spypublic <T> T Spy(java.util.Map<java.lang.String,java.lang.Object> options,
java.lang.Class<T> type)
def person = Spy(Person, name: "myPerson") // type is Person.class, name is "myPerson"
Spy in interface MockFactoryT - the class type of the spyoptions - optional options for creating the spytype - the class type of the spypublic <T> T createMock(java.lang.String name,
java.lang.Class<T> type,
org.spockframework.mock.MockNature nature,
java.util.Map<java.lang.String,java.lang.Object> options)
public <T> T createMock(java.lang.String name,
T obj,
org.spockframework.mock.MockNature nature,
java.util.Map<java.lang.String,java.lang.Object> options)