Package org.mockito
Enum Answers
- All Implemented Interfaces:
Serializable
,Comparable<Answers>
,java.lang.constant.Constable
,Answer<Object>
Enumeration of pre-configured mock answers
You can use it to pass extra parameters to @Mock annotation, see more info here: Mock
Example:
@Mock(answer = RETURNS_DEEP_STUBS) UserProvider userProvider;
This is not the full list of Answers available in Mockito. Some interesting answers can be found in org.mockito.stubbing.answers package.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionAn answer that calls the real methods (used for partial mocks).An answer that returns deep stubs (not mocks).The default configured answer of every mock.An answer that returns mocks (not stubs).An answer that tries to return itself.An answer that returns smart-nulls. -
Method Summary
-
Enum Constant Details
-
RETURNS_DEFAULTS
The default configured answer of every mock.Please see the
Mockito.RETURNS_DEFAULTS
documentation for more details.- See Also:
-
RETURNS_SMART_NULLS
An answer that returns smart-nulls.Please see the
Mockito.RETURNS_SMART_NULLS
documentation for more details.- See Also:
-
RETURNS_MOCKS
An answer that returns mocks (not stubs).Please see the
Mockito.RETURNS_MOCKS
documentation for more details.- See Also:
-
RETURNS_DEEP_STUBS
An answer that returns deep stubs (not mocks).Please see the
Mockito.RETURNS_DEEP_STUBS
documentation for more details.- See Also:
-
CALLS_REAL_METHODS
An answer that calls the real methods (used for partial mocks).Please see the
Mockito.CALLS_REAL_METHODS
documentation for more details.- See Also:
-
RETURNS_SELF
An answer that tries to return itself. This is useful for mockingBuilders
.Please see the
Mockito.RETURNS_SELF
documentation for more details.- See Also:
-
-
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
-
answer
-