org.mockito.stubbing
public interface Stubbing
MockingDetails.getStubbings()
.Modifier and Type | Method and Description |
---|---|
Invocation |
getInvocation()
Returns the method invocation that is stubbed.
|
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()
.