Enum MockNature

java.lang.Object
java.lang.Enum<MockNature>
org.spockframework.mock.MockNature
All Implemented Interfaces:
Serializable, Comparable<MockNature>, java.lang.constant.Constable

@Beta public enum MockNature extends 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 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 Constants
    Enum Constant
    Description
    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 is ZeroOrNullResponse.
    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 is CallRealMethodResponse.
    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 is EmptyOrDummyResponse.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns 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[]
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • 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 is ZeroOrNullResponse.
    • 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 is EmptyOrDummyResponse.
    • 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 is CallRealMethodResponse.
  • Method Details

    • values

      public static MockNature[] 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

      public static MockNature valueOf(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:
      IllegalArgumentException - if this enum type has no constant with the specified name
      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