Class StubbedInvocationMatcher

java.lang.Object
org.mockito.internal.invocation.InvocationMatcher
org.mockito.internal.stubbing.StubbedInvocationMatcher
All Implemented Interfaces:
Serializable, DescribedInvocation, MatchableInvocation, Answer, Stubbing

public class StubbedInvocationMatcher extends InvocationMatcher implements Serializable, Stubbing
See Also:
  • Constructor Details

  • Method Details

    • answer

      public Object answer(InvocationOnMock invocation) throws Throwable
      Specified by:
      answer in interface Answer
      Parameters:
      invocation - the invocation on the mock.
      Returns:
      the value to be returned
      Throws:
      Throwable - the throwable to be thrown
    • addAnswer

      public void addAnswer(Answer answer)
    • markStubUsed

      public void markStubUsed(DescribedInvocation usedAt)
    • wasUsed

      public boolean wasUsed()
      Description copied from interface: Stubbing
      Informs if the stubbing was used

      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().

      Specified by:
      wasUsed in interface Stubbing
    • toString

      public String toString()
      Description copied from interface: DescribedInvocation
      Describes the invocation in the human friendly way.
      Specified by:
      toString in interface DescribedInvocation
      Overrides:
      toString in class InvocationMatcher
      Returns:
      the description of this invocation.
    • getStrictness

      public Strictness getStrictness()
      Description copied from interface: Stubbing
      Informs about the Strictness level of this stubbing. For more information about setting strictness for stubbings see Mockito.lenient().
      Specified by:
      getStrictness in interface Stubbing