public class StubbedInvocationMatcher extends InvocationMatcher implements java.io.Serializable, Stubbing
Modifier and Type | Field and Description |
---|---|
private java.util.Queue<Answer> |
answers |
private static long |
serialVersionUID |
private Strictness |
strictness |
private DescribedInvocation |
usedAt |
Constructor and Description |
---|
StubbedInvocationMatcher(Answer answer,
MatchableInvocation invocation,
Strictness strictness) |
Modifier and Type | Method and Description |
---|---|
void |
addAnswer(Answer answer) |
java.lang.Object |
answer(InvocationOnMock invocation) |
Strictness |
getStrictness()
Informs about the
Strictness level of this stubbing. |
void |
markStubUsed(DescribedInvocation usedAt) |
java.lang.String |
toString()
Describes the invocation in the human friendly way.
|
boolean |
wasUsed()
Informs if the stubbing was used
|
captureArgumentsFrom, createFrom, getInvocation, getLocation, getMatchers, getMethod, hasSameMethod, hasSimilarMethod, matches
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getInvocation
private static final long serialVersionUID
private final java.util.Queue<Answer> answers
private final Strictness strictness
private DescribedInvocation usedAt
public StubbedInvocationMatcher(Answer answer, MatchableInvocation invocation, Strictness strictness)
public java.lang.Object answer(InvocationOnMock invocation) throws java.lang.Throwable
public void addAnswer(Answer answer)
public void markStubUsed(DescribedInvocation usedAt)
public boolean wasUsed()
Stubbing
What does it mean 'used stubbing'?
Stubbing like when(mock.foo()).thenReturn(true)
is considered used
when the method mock.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()
.
public java.lang.String toString()
DescribedInvocation
toString
in interface DescribedInvocation
toString
in class InvocationMatcher
public Strictness getStrictness()
Stubbing
Strictness
level of this stubbing.
For more information about setting strictness for stubbings see Mockito.lenient()
.getStrictness
in interface Stubbing