@NotExtensible public interface Stubbing extends Answer
MockingDetails.getStubbings()
.
Since 2.10.0 this interface extends Answer
.
Extending Answer is backwards compatible because Stubbing interface is not extensible (see NotExtensible
).
Extending Answer was needed to improve Mockito domain model and simplify the code.
Modifier and Type | Method and Description |
---|---|
Invocation |
getInvocation()
Returns the method invocation that is stubbed.
|
Strictness |
getStrictness()
Informs about the
Strictness level of this stubbing. |
boolean |
wasUsed()
Informs if the stubbing was used
|
Invocation getInvocation()
when(mock.foo()).thenReturn(true)
the invocation is mock.foo()
.
The invocation instance is mutable. It is not recommended to modify the state of invocation because it will influence mock behavior.
To understand how this method is useful, see the description at MockingDetails.getStubbings()
.
boolean wasUsed()
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()
.
@Incubating Strictness getStrictness()
Strictness
level of this stubbing.
For more information about setting strictness for stubbings see Mockito.lenient()
.