Class Reporter

java.lang.Object
org.mockito.exceptions.Reporter

public class Reporter extends Object
Reports verification and misusing errors.

One of the key points of mocking library is proper verification/exception messages. All messages in one place makes it easier to tune and amend them.

Reporter can be injected and therefore is easily testable.

Generally, exception messages are full of line breaks to make them easy to read (xunit plugins take only fraction of screen on modern IDEs).

  • Constructor Details

    • Reporter

      public Reporter()
  • Method Details

    • checkedExceptionInvalid

      public void checkedExceptionInvalid(Throwable t)
    • cannotStubWithNullThrowable

      public void cannotStubWithNullThrowable()
    • unfinishedStubbing

      public void unfinishedStubbing(Location location)
    • incorrectUseOfApi

      public void incorrectUseOfApi()
    • missingMethodInvocation

      public void missingMethodInvocation()
    • unfinishedVerificationException

      public void unfinishedVerificationException(Location location)
    • notAMockPassedToVerify

      public void notAMockPassedToVerify(Class type)
    • nullPassedToVerify

      public void nullPassedToVerify()
    • notAMockPassedToWhenMethod

      public void notAMockPassedToWhenMethod()
    • nullPassedToWhenMethod

      public void nullPassedToWhenMethod()
    • mocksHaveToBePassedToVerifyNoMoreInteractions

      public void mocksHaveToBePassedToVerifyNoMoreInteractions()
    • notAMockPassedToVerifyNoMoreInteractions

      public void notAMockPassedToVerifyNoMoreInteractions()
    • nullPassedToVerifyNoMoreInteractions

      public void nullPassedToVerifyNoMoreInteractions()
    • notAMockPassedWhenCreatingInOrder

      public void notAMockPassedWhenCreatingInOrder()
    • nullPassedWhenCreatingInOrder

      public void nullPassedWhenCreatingInOrder()
    • mocksHaveToBePassedWhenCreatingInOrder

      public void mocksHaveToBePassedWhenCreatingInOrder()
    • inOrderRequiresFamiliarMock

      public void inOrderRequiresFamiliarMock()
    • invalidUseOfMatchers

      public void invalidUseOfMatchers(int expectedMatchersCount, List<LocalizedMatcher> recordedMatchers)
    • incorrectUseOfAdditionalMatchers

      public void incorrectUseOfAdditionalMatchers(String additionalMatcherName, int expectedSubMatchersCount, Collection<LocalizedMatcher> matcherStack)
    • stubPassedToVerify

      public void stubPassedToVerify()
    • reportNoSubMatchersFound

      public void reportNoSubMatchersFound(String additionalMatcherName)
    • argumentsAreDifferent

      public void argumentsAreDifferent(String wanted, String actual, Location actualLocation)
    • wantedButNotInvoked

      public void wantedButNotInvoked(DescribedInvocation wanted)
    • wantedButNotInvoked

      public void wantedButNotInvoked(DescribedInvocation wanted, List<? extends DescribedInvocation> invocations)
    • wantedButNotInvokedInOrder

      public void wantedButNotInvokedInOrder(DescribedInvocation wanted, DescribedInvocation previous)
    • tooManyActualInvocations

      public void tooManyActualInvocations(int wantedCount, int actualCount, DescribedInvocation wanted, Location firstUndesired)
    • neverWantedButInvoked

      public void neverWantedButInvoked(DescribedInvocation wanted, Location firstUndesired)
    • tooManyActualInvocationsInOrder

      public void tooManyActualInvocationsInOrder(int wantedCount, int actualCount, DescribedInvocation wanted, Location firstUndesired)
    • tooLittleActualInvocations

      public void tooLittleActualInvocations(Discrepancy discrepancy, DescribedInvocation wanted, Location lastActualLocation)
    • tooLittleActualInvocationsInOrder

      public void tooLittleActualInvocationsInOrder(Discrepancy discrepancy, DescribedInvocation wanted, Location lastActualLocation)
    • noMoreInteractionsWanted

      public void noMoreInteractionsWanted(Invocation undesired, List<VerificationAwareInvocation> invocations)
    • noMoreInteractionsWantedInOrder

      public void noMoreInteractionsWantedInOrder(Invocation undesired)
    • cannotMockFinalClass

      public void cannotMockFinalClass(Class<?> clazz)
    • cannotStubVoidMethodWithAReturnValue

      public void cannotStubVoidMethodWithAReturnValue(String methodName)
    • onlyVoidMethodsCanBeSetToDoNothing

      public void onlyVoidMethodsCanBeSetToDoNothing()
    • wrongTypeOfReturnValue

      public void wrongTypeOfReturnValue(String expectedType, String actualType, String methodName)
    • wantedAtMostX

      public void wantedAtMostX(int maxNumberOfInvocations, int foundSize)
    • misplacedArgumentMatcher

      public void misplacedArgumentMatcher(List<LocalizedMatcher> lastMatchers)
    • smartNullPointerException

      public void smartNullPointerException(String invocation, Location location)
    • noArgumentValueWasCaptured

      public void noArgumentValueWasCaptured()
    • extraInterfacesDoesNotAcceptNullParameters

      public void extraInterfacesDoesNotAcceptNullParameters()
    • extraInterfacesAcceptsOnlyInterfaces

      public void extraInterfacesAcceptsOnlyInterfaces(Class<?> wrongType)
    • extraInterfacesCannotContainMockedType

      public void extraInterfacesCannotContainMockedType(Class<?> wrongType)
    • extraInterfacesRequiresAtLeastOneInterface

      public void extraInterfacesRequiresAtLeastOneInterface()
    • mockedTypeIsInconsistentWithSpiedInstanceType

      public void mockedTypeIsInconsistentWithSpiedInstanceType(Class<?> mockedType, Object spiedInstance)
    • cannotCallAbstractRealMethod

      public void cannotCallAbstractRealMethod()
    • cannotVerifyToString

      public void cannotVerifyToString()
    • moreThanOneAnnotationNotAllowed

      public void moreThanOneAnnotationNotAllowed(String fieldName)
    • unsupportedCombinationOfAnnotations

      public void unsupportedCombinationOfAnnotations(String undesiredAnnotationOne, String undesiredAnnotationTwo)
    • cannotInitializeForSpyAnnotation

      public void cannotInitializeForSpyAnnotation(String fieldName, Exception details)
    • cannotInitializeForInjectMocksAnnotation

      public void cannotInitializeForInjectMocksAnnotation(String fieldName, Exception details)
    • atMostAndNeverShouldNotBeUsedWithTimeout

      public void atMostAndNeverShouldNotBeUsedWithTimeout()
    • fieldInitialisationThrewException

      public void fieldInitialisationThrewException(Field field, Throwable details)
    • invocationListenerDoesNotAcceptNullParameters

      public void invocationListenerDoesNotAcceptNullParameters()
    • invocationListenersRequiresAtLeastOneListener

      public void invocationListenersRequiresAtLeastOneListener()
    • invocationListenerThrewException

      public void invocationListenerThrewException(InvocationListener listener, Throwable listenerThrowable)
    • cannotInjectDependency

      public void cannotInjectDependency(Field field, Object matchingMock, Exception details)
    • mockedTypeIsInconsistentWithDelegatedInstanceType

      public void mockedTypeIsInconsistentWithDelegatedInstanceType(Class mockedType, Object delegatedInstance)
    • spyAndDelegateAreMutuallyExclusive

      public void spyAndDelegateAreMutuallyExclusive()
    • invalidArgumentRangeAtIdentityAnswerCreationTime

      public void invalidArgumentRangeAtIdentityAnswerCreationTime()
    • invalidArgumentPositionRangeAtInvocationTime

      public int invalidArgumentPositionRangeAtInvocationTime(InvocationOnMock invocation, boolean willReturnLastParameter, int argumentIndex)
    • wrongTypeOfArgumentToReturn

      public void wrongTypeOfArgumentToReturn(InvocationOnMock invocation, String expectedType, Class actualType, int argumentIndex)
    • defaultAnswerDoesNotAcceptNullParameter

      public void defaultAnswerDoesNotAcceptNullParameter()
    • serializableWontWorkForObjectsThatDontImplementSerializable

      public void serializableWontWorkForObjectsThatDontImplementSerializable(Class classToMock)
    • delegatedMethodHasWrongReturnType

      public void delegatedMethodHasWrongReturnType(Method mockMethod, Method delegateMethod, Object mock, Object delegate)
    • delegatedMethodDoesNotExistOnDelegate

      public void delegatedMethodDoesNotExistOnDelegate(Method mockMethod, Object mock, Object delegate)
    • usingConstructorWithFancySerializable

      public void usingConstructorWithFancySerializable(SerializableMode mode)