Package org.mockito.internal.stubbing
Class StubbedInvocationMatcher
java.lang.Object
org.mockito.internal.invocation.InvocationMatcher
org.mockito.internal.stubbing.StubbedInvocationMatcher
- All Implemented Interfaces:
Serializable
,DescribedInvocation
,MatchableInvocation
,Answer
,Stubbing
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionStubbedInvocationMatcher
(Answer answer, MatchableInvocation invocation, Strictness strictness) -
Method Summary
Modifier and TypeMethodDescriptionvoid
answer
(InvocationOnMock invocation) Informs about theStrictness
level of this stubbing.void
markStubUsed
(DescribedInvocation usedAt) toString()
Describes the invocation in the human friendly way.boolean
wasUsed()
Informs if the stubbing was usedMethods inherited from class org.mockito.internal.invocation.InvocationMatcher
captureArgumentsFrom, createFrom, getInvocation, getLocation, getMatchers, getMethod, hasSameMethod, hasSimilarMethod, matches
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.mockito.stubbing.Stubbing
getInvocation
-
Constructor Details
-
StubbedInvocationMatcher
public StubbedInvocationMatcher(Answer answer, MatchableInvocation invocation, Strictness strictness)
-
-
Method Details
-
answer
-
addAnswer
-
markStubUsed
-
wasUsed
public boolean wasUsed()Description copied from interface:Stubbing
Informs if the stubbing was usedWhat does it mean 'used stubbing'? Stubbing like
when(mock.foo()).thenReturn(true)
is considered used when the methodmock.foo()
is actually invoked during the execution of code under test.This method is used internally by Mockito to report and detect unused stubbings. Unused stubbings are dead code and should be deleted to increase clarity of tests (see
MockitoHint
.To understand how this method is useful, see the description at
MockingDetails.getStubbings()
. -
toString
Description copied from interface:DescribedInvocation
Describes the invocation in the human friendly way.- Specified by:
toString
in interfaceDescribedInvocation
- Overrides:
toString
in classInvocationMatcher
- Returns:
- the description of this invocation.
-
getStrictness
Description copied from interface:Stubbing
Informs about theStrictness
level of this stubbing. For more information about setting strictness for stubbings seeMockito.lenient()
.- Specified by:
getStrictness
in interfaceStubbing
-