Package org.spockframework.mock
Enum MockNature
- java.lang.Object
-
- java.lang.Enum<MockNature>
-
- org.spockframework.mock.MockNature
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<MockNature>
@Beta public enum MockNature extends java.lang.Enum<MockNature>
A named set of defaults for a mock's configuration options. A mock nature is chosen at mock creation time, typically by selecting the appropriateMockingApi
factory method.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description 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
.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
.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
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IDefaultResponse
getDefaultResponse()
Returns the strategy for responding to unexpected method calls.boolean
isUseObjenesis()
Tells whether class-based mock objects should be instantiated with the Objenesis library (if available), or by calling a real constructor.boolean
isVerified()
Tells whether method calls should be verified.static MockNature
valueOf(java.lang.String name)
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 Detail
-
MOCK
public static final MockNature 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
public static final MockNature 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
public static final MockNature 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 Detail
-
values
public static MockNature[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (MockNature c : MockNature.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static MockNature valueOf(java.lang.String name)
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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- 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
public IDefaultResponse getDefaultResponse()
Returns the strategy for responding to unexpected method calls.- Returns:
- the strategy for responding to unexpected method calls
-
-