Package org.spockframework.mock
Enum MockNature
- All Implemented Interfaces:
Serializable
,Comparable<MockNature>
,java.lang.constant.Constable
A named set of defaults for a mock's configuration options. A mock nature is chosen at
mock creation time, typically by selecting the appropriate
MockingApi
factory method.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionA mock object whose method calls are verified, which instantiates class-based mock objects with Objenesis, and whose strategy for responding to unexpected method calls isZeroOrNullResponse
.A mock object whose method calls are verified, which instantiates class-based mock objects by calling a real constructor, and whose strategy for responding to unexpected method calls isCallRealMethodResponse
.A mock object whose method calls are not verified, which instantiates class-based mock objects with Objenesis, and whose strategy for responding to unexpected method calls isEmptyOrDummyResponse
. -
Method Summary
Modifier and TypeMethodDescriptionReturns the strategy for responding to unexpected method calls.boolean
Tells whether class-based mock objects should be instantiated with the Objenesis library (if available), or by calling a real constructor.boolean
Tells whether method calls should be verified.static MockNature
Returns the enum constant of this type with the specified name.static MockNature[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
MOCK
A mock object whose method calls are verified, which instantiates class-based mock objects with Objenesis, and whose strategy for responding to unexpected method calls isZeroOrNullResponse
. -
STUB
A mock object whose method calls are not verified, which instantiates class-based mock objects with Objenesis, and whose strategy for responding to unexpected method calls isEmptyOrDummyResponse
. -
SPY
A mock object whose method calls are verified, which instantiates class-based mock objects by calling a real constructor, and whose strategy for responding to unexpected method calls isCallRealMethodResponse
.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
isVerified
public boolean isVerified()Tells whether method calls should be verified.- Returns:
- whether method calls should be verified
-
isUseObjenesis
public boolean isUseObjenesis()Tells whether class-based mock objects should be instantiated with the Objenesis library (if available), or by calling a real constructor.- Returns:
- whether class-based mock objects should be instantiated with the Objenesis library (if available), or by calling a real constructor
-
getDefaultResponse
Returns the strategy for responding to unexpected method calls.- Returns:
- the strategy for responding to unexpected method calls
-