Package org.spockframework.mock
Interface IMockConfiguration
-
- All Known Implementing Classes:
MockConfiguration
@Beta public interface IMockConfiguration
Configuration options for mock objects. Once a mock object has been created, its configuration cannot be changed.getNature()
andgetImplementation()
are mandatory options that are typically determined by choosing the appropriateMockingApi
factory method.getType()
is a mandatory option that is typically passed directly to aMockingApi
factory method, or inferred from the left-hand side of the enclosing variable assignment. The remaining options are optional and are typically passed to aMockingApi
factory method as named arguments. For example,getConstructorArgs()
corresponds to theconstructorArgs:
named argument,isGlobal()
to theglobal:
named argument, etc.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<java.lang.Object>
getConstructorArgs()
Returns the constructor arguments to be used for creating the mock object.IDefaultResponse
getDefaultResponse()
Returns the default response strategy for the mock object.MockImplementation
getImplementation()
Returns the implementation of the mock object.java.lang.String
getName()
Returns the name of the mock object.MockNature
getNature()
Returns the nature of the mock object.java.lang.Class<?>
getType()
Returns the interface or class type of the mock object.boolean
isGlobal()
Tells whether a mock object stands in for all objects of the mocked type, or just for itself.boolean
isUseObjenesis()
Tells whether the Objenesis library, if available on the class path, should be used for constructing the mock object, rather than calling a constructor.boolean
isVerified()
Tells whether invocations on the mock object should be verified.
-
-
-
Method Detail
-
getName
java.lang.String getName()
Returns the name of the mock object.- Returns:
- the name of the mock object
-
getType
java.lang.Class<?> getType()
Returns the interface or class type of the mock object.- Returns:
- the interface or class type of the mock object
-
getNature
MockNature getNature()
Returns the nature of the mock object. A nature is a named set of defaults for mock configuration options.- Returns:
- the nature of the mock object
-
getImplementation
MockImplementation getImplementation()
Returns the implementation of the mock object.- Returns:
- the implementation of the mock object
-
getConstructorArgs
java.util.List<java.lang.Object> getConstructorArgs()
Returns the constructor arguments to be used for creating the mock object.- Returns:
- the constructor arguments to be used for creating the mock object
-
getDefaultResponse
IDefaultResponse getDefaultResponse()
Returns the default response strategy for the mock object.- Returns:
- the default response strategy for the mock object
-
isGlobal
boolean isGlobal()
Tells whether a mock object stands in for all objects of the mocked type, or just for itself. This is an optional feature that may not be supported by a particularMockImplementation
.- Returns:
- whether a mock object stands in for all objects of the mocked type, or just for itself
-
isVerified
boolean isVerified()
Tells whether invocations on the mock object should be verified. If (@code false}, invocations on the mock object will not be matched against interactions that have a cardinality.- Returns:
- whether invocations on the mock object should be verified
-
isUseObjenesis
boolean isUseObjenesis()
Tells whether the Objenesis library, if available on the class path, should be used for constructing the mock object, rather than calling a constructor.- Returns:
- whether the Objenesis library should be used for constructing the mock object
-
-