@Beta public class DetachedMockFactory extends 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(String name,
Class<T> type,
org.spockframework.mock.MockNature nature,
Map<String,Object> options) |
<T> T |
createMock(String name,
T obj,
org.spockframework.mock.MockNature nature,
Map<String,Object> options) |
<T> T |
Mock(Class<T> type)
Creates a mock with the specified type.
|
<T> T |
Mock(Map<String,Object> options,
Class<T> type)
Creates a mock with the specified options and type.
|
<T> T |
Spy(Class<T> type)
Creates a spy with the specified type.
|
<T> T |
Spy(Map<String,Object> options,
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(Class<T> type)
Creates a stub with the specified type.
|
<T> T |
Stub(Map<String,Object> options,
Class<T> type)
Creates a stub with the specified options and type.
|
public <T> T Mock(Class<T> type)
def person = Mock(Person) // type is Person.class, name is "person"
Mock
in interface MockFactory
T
- the interface or class type of the mocktype
- the interface or class type of the mockpublic <T> T Mock(Map<String,Object> options, Class<T> type)
def person = Mock(Person, name: "myPerson") // type is Person.class, name is "myPerson"
Mock
in interface MockFactory
T
- 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(Class<T> type)
def person = Stub(Person) // type is Person.class, name is "person"
Stub
in interface MockFactory
T
- the interface or class type of the stubtype
- the interface or class type of the stubpublic <T> T Stub(Map<String,Object> options, Class<T> type)
def person = Stub(Person, name: "myPerson") // type is Person.class, name is "myPerson"
Stub
in interface MockFactory
T
- 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(Class<T> type)
def person = Spy(Person) // type is Person.class, name is "person"
Spy
in interface MockFactory
T
- the class type of the spytype
- the class type of the spypublic <T> T Spy(T obj)
MockFactory
def person = Spy(new Person()) // type is Person.class, name is "person"
Spy
in interface MockFactory
T
- the class type of the spyobj
- the instance to spypublic <T> T Spy(Map<String,Object> options, Class<T> type)
def person = Spy(Person, name: "myPerson") // type is Person.class, name is "myPerson"
Spy
in interface MockFactory
T
- the class type of the spyoptions
- optional options for creating the spytype
- the class type of the spypublic <T> T createMock(String name, Class<T> type, org.spockframework.mock.MockNature nature, Map<String,Object> options)