public interface MockFactory
MockingApi or DetachedMockFactory for more examples.| Modifier and Type | Method and Description |
|---|---|
<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.
|
<T> T Mock(Class<T> type)
def person = Mock(Person) // type is Person.class, name is "person"
T - the interface or class type of the mocktype - the interface or class type of the mock@Beta <T> T Mock(Map<String,Object> options, Class<T> type)
def person = Mock(Person, name: "myPerson") // type is Person.class, name is "myPerson"
T - the interface or class type of the mockoptions - optional options for creating the mocktype - the interface or class type of the mock@Beta <T> T Stub(Class<T> type)
def person = Stub(Person) // type is Person.class, name is "person"
T - the interface or class type of the stubtype - the interface or class type of the stub@Beta <T> T Stub(Map<String,Object> options, Class<T> type)
def person = Stub(Person, name: "myPerson") // type is Person.class, name is "myPerson"
T - the interface or class type of the stuboptions - optional options for creating the stubtype - the interface or class type of the stub@Beta <T> T Spy(Class<T> type)
def person = Spy(Person) // type is Person.class, name is "person"
T - the class type of the spytype - the class type of the spy@Beta <T> T Spy(T obj)
def person = Spy(new Person()) // type is Person.class, name is "person"
T - the class type of the spyobj - the instance to spy@Beta <T> T Spy(Map<String,Object> options, Class<T> type)
def person = Spy(Person, name: "myPerson") // type is Person.class, name is "myPerson"
T - the class type of the spyoptions - optional options for creating the spytype - the class type of the spy