Package org.mockito.mock
Interface MockCreationSettings<T>
-
@NotExtensible public interface MockCreationSettings<T>
Informs about the mock settings. An immutable view ofMockSettings.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description Object[]getConstructorArgs()Used when arguments should be passed to the mocked object's constructor, regardless of whether these arguments are supplied directly, or whether they include the outer instance.Answer<?>getDefaultAnswer()the default answer for this mock, seeMockSettings.defaultAnswer(org.mockito.stubbing.Answer).Set<Class<?>>getExtraInterfaces()the extra interfaces the mock object should implement.List<InvocationListener>getInvocationListeners()InvocationListenerinstances attached to this mock, seeMockSettings.invocationListeners(InvocationListener...).StringgetMockMaker()Returns theMockMakerwhich shall be used to create the mock.MockNamegetMockName()the name of this mock, as printed on verification errors; seeMockSettings.name(java.lang.String).ObjectgetOuterClassInstance()Used when mocking non-static inner classes in conjunction withisUsingConstructor()SerializableModegetSerializableMode()ObjectgetSpiedInstance()the spied instance - needed for spies.StrictnessgetStrictness()Sets strictness level for the mock, e.g.List<StubbingLookupListener>getStubbingLookupListeners()ReturnsStubbingLookupListenerinstances attached to this mock viaMockSettings.stubbingLookupListeners(StubbingLookupListener...).Class<T>getTypeToMock()Mocked type.List<VerificationStartedListener>getVerificationStartedListeners()VerificationStartedListenerinstances attached to this mock, seeMockSettings.verificationStartedListeners(VerificationStartedListener...)booleanisLenient()Deprecated.UsegetStrictness()instead.booleanisSerializable()if the mock is serializable, seeMockSettings.serializable().booleanisStripAnnotations()Whether the mock should not make a best effort to preserve annotations.booleanisStubOnly()Whether the mock is only for stubbing, i.e.booleanisUsingConstructor()Informs whether the mock instance should be created via constructor
-
-
-
Method Detail
-
getTypeToMock
Class<T> getTypeToMock()
Mocked type. An interface or class the mock should implement / extend.
-
getExtraInterfaces
Set<Class<?>> getExtraInterfaces()
the extra interfaces the mock object should implement.
-
getMockName
MockName getMockName()
the name of this mock, as printed on verification errors; seeMockSettings.name(java.lang.String).
-
getDefaultAnswer
Answer<?> getDefaultAnswer()
the default answer for this mock, seeMockSettings.defaultAnswer(org.mockito.stubbing.Answer).
-
getSpiedInstance
Object getSpiedInstance()
the spied instance - needed for spies.
-
isSerializable
boolean isSerializable()
if the mock is serializable, seeMockSettings.serializable().
-
getSerializableMode
SerializableMode getSerializableMode()
- Returns:
- the serializable mode of this mock
-
isStubOnly
boolean isStubOnly()
Whether the mock is only for stubbing, i.e. does not remember parameters on its invocation and therefore cannot be used for verification
-
isStripAnnotations
boolean isStripAnnotations()
Whether the mock should not make a best effort to preserve annotations.
-
getStubbingLookupListeners
List<StubbingLookupListener> getStubbingLookupListeners()
ReturnsStubbingLookupListenerinstances attached to this mock viaMockSettings.stubbingLookupListeners(StubbingLookupListener...). The resulting list is mutable, you can add/remove listeners even after the mock was created.For more details see
StubbingLookupListener.- Since:
- 2.24.6
-
getInvocationListeners
List<InvocationListener> getInvocationListeners()
InvocationListenerinstances attached to this mock, seeMockSettings.invocationListeners(InvocationListener...).
-
getVerificationStartedListeners
List<VerificationStartedListener> getVerificationStartedListeners()
VerificationStartedListenerinstances attached to this mock, seeMockSettings.verificationStartedListeners(VerificationStartedListener...)- Since:
- 2.11.0
-
isUsingConstructor
boolean isUsingConstructor()
Informs whether the mock instance should be created via constructor- Since:
- 1.10.12
-
getConstructorArgs
Object[] getConstructorArgs()
Used when arguments should be passed to the mocked object's constructor, regardless of whether these arguments are supplied directly, or whether they include the outer instance.- Returns:
- An array of arguments that are passed to the mocked object's constructor. If
getOuterClassInstance()is available, it is prepended to the passed arguments. - Since:
- 2.7.14
-
getOuterClassInstance
Object getOuterClassInstance()
Used when mocking non-static inner classes in conjunction withisUsingConstructor()- Returns:
- the outer class instance used for creation of the mock object via the constructor.
- Since:
- 1.10.12
-
isLenient
@Deprecated boolean isLenient()
Deprecated.UsegetStrictness()instead. Informs if the mock was created with "lenient" strictness, e.g. havingStrictness.LENIENTcharacteristic. For more information about using mocks with lenient strictness, seeMockSettings.lenient().- Since:
- 2.20.0
-
getStrictness
Strictness getStrictness()
Sets strictness level for the mock, e.g. havingStrictness.STRICT_STUBScharacteristic. For more information about using mocks with custom strictness, seeMockSettings.strictness(Strictness).- Since:
- 4.6.0
-
getMockMaker
String getMockMaker()
Returns theMockMakerwhich shall be used to create the mock. When the return value isnull, the default shall be used.- Since:
- 4.8.0
- See Also:
MockSettings.mockMaker(String)
-
-