Interface Invocation

All Superinterfaces:
DescribedInvocation, InvocationOnMock, Serializable

@NotExtensible public interface Invocation extends InvocationOnMock, DescribedInvocation
A method call on a mock object. Contains all information and state needed for the Mockito framework to operate. This API might be useful for developers who extend Mockito.

The javadoc does not have lots of examples or documentation because its audience is different. Vast majority of users don't need to use the Invocation. It's mostly useful for other framework authors that extend Mockito.

Creating own implementations of this interface is not recommended. If you are a framework integrator and you need to programmatically create instances of invocations see InvocationFactory.

Since:
1.9.5
  • Method Details

    • isVerified

      boolean isVerified()
      Returns:
      whether the invocation has been already verified. Needed for Mockito.verifyNoMoreInteractions(Object...)
    • getSequenceNumber

      int getSequenceNumber()
      Returns:
      the sequence number of the Invocation. Useful to determine the order of invocations. Used by verification in order.
    • getLocation

      Location getLocation()
      Description copied from interface: DescribedInvocation
      The place in the code where the invocation happened.
      Specified by:
      getLocation in interface DescribedInvocation
      Returns:
      the location in code of this invocation.
    • getArgumentsAsMatchers

      List<ArgumentMatcher> getArgumentsAsMatchers()
      Wraps each argument using ArgumentMatchers.eq(Object) or AdditionalMatchers.aryEq(Object[]) Used internally for the purposes of human-readable invocation printing.
      Returns:
      a list of ArgumentMatcher wrapping each of this invocation arguments
      Since:
      2.25.6
    • getRawReturnType

      Class<?> getRawReturnType()
      Returns unprocessed arguments whereas InvocationOnMock.getArguments() returns arguments already processed (e.g. varargs expended, etc.).
      Returns:
      unprocessed arguments, exactly as provided to this invocation.
      Since:
      4.7.0
    • markVerified

      void markVerified()
      Marks this invocation as verified so that it will not cause verification error at Mockito.verifyNoMoreInteractions(Object...)
    • stubInfo

      StubInfo stubInfo()
      Returns:
      the stubbing information for this invocation. May return null - this means the invocation was not stubbed.
    • markStubbed

      void markStubbed(StubInfo stubInfo)
      Marks this invocation as stubbed.
      Parameters:
      stubInfo - the information about stubbing.
    • isIgnoredForVerification

      boolean isIgnoredForVerification()
      Informs if the invocation participates in verify-no-more-invocations or verification in order.
      Returns:
      whether this invocation should be ignored for the purposes of verify-no-more-invocations or verification in order.
    • ignoreForVerification

      void ignoreForVerification()
      Configures this invocation to be ignored for verify-no-more-invocations or verification in order. See also isIgnoredForVerification()