Class MockitoAssertionError

java.lang.Object
java.lang.Throwable
java.lang.Error
java.lang.AssertionError
org.mockito.exceptions.base.MockitoAssertionError
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ArgumentsAreDifferent, MoreThanAllowedActualInvocations, NeverWantedButInvoked, NoInteractionsWanted, TooFewActualInvocations, TooManyActualInvocations, VerificationInOrderFailure, WantedButNotInvoked

public class MockitoAssertionError extends AssertionError
Base class for verification errors emitted by Mockito. Verification errors are triggered by "verify" methods, for example Mockito.verify(Object) or Mockito.verifyNoMoreInteractions(Object...). All error classes that inherit from this class will have the stack trace filtered. Filtering removes Mockito internal stack trace elements to provide clean stack traces and improve productivity.

The stack trace is filtered from mockito calls if you are using Throwable.getStackTrace(). For debugging purpose though you can still access the full stacktrace using getUnfilteredStackTrace(). However note that other calls related to the stackTrace will refer to the filter stacktrace.

Advanced users and framework integrators can control stack trace filtering behavior via StackTraceCleanerProvider classpath plugin.

See Also:
  • Constructor Details

    • MockitoAssertionError

      public MockitoAssertionError(String message)
    • MockitoAssertionError

      public MockitoAssertionError(MockitoAssertionError error, String message)
      Creates a copy of the given assertion error with the custom failure message prepended.
      Parameters:
      error - The assertion error to copy
      message - The custom message to prepend
      Since:
      2.1.0
    • MockitoAssertionError

      public MockitoAssertionError(AssertionError error, String message)
      Creates a copy of the given assertion error with the custom failure message prepended.
      Parameters:
      error - The assertion error to copy
      message - The custom message to prepend
      Since:
      3.3.13
  • Method Details