Package org.spockframework.mock
Interface IMockConfiguration
- All Known Implementing Classes:
MockConfiguration
Configuration options for mock objects. Once a mock object has been created, its configuration cannot be changed.
getNature()
and getImplementation()
are mandatory options that are typically
determined by choosing the appropriate MockingApi
factory method. getType()
is a mandatory option that is typically passed directly to a MockingApi
factory method, or inferred
from the left-hand side of the enclosing variable assignment. The remaining options are optional and are
typically passed to a MockingApi
factory method as named arguments. For example,
getConstructorArgs()
corresponds to the constructorArgs:
named argument,
isGlobal()
to the global:
named argument, etc.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the constructor arguments to be used for creating the mock object.Returns the default response strategy for the mock object.Returns the implementation of the mock object.getName()
Returns the name of the mock object.Returns the nature of the mock object.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
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
Tells whether invocations on the mock object should be verified.
-
Method Details
-
getName
String getName()Returns the name of the mock object.- Returns:
- the name of the mock object
-
getType
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
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
-