org.mockito.exceptions
Class Reporter

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

public class Reporter
extends java.lang.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 Summary
Reporter()
           
 
Method Summary
 void argumentsAreDifferent(java.lang.String wanted, java.lang.String actual, Location actualLocation)
           
 void atMostShouldNotBeUsedWithTimeout()
           
 void cannotCallRealMethodOnInterface()
           
 void cannotInitializeForInjectMocksAnnotation(java.lang.String fieldName, java.lang.Exception details)
           
 void cannotInitializeForSpyAnnotation(java.lang.String fieldName, java.lang.Exception details)
           
 void cannotInjectDependency(java.lang.reflect.Field field, java.lang.Object matchingMock, java.lang.Exception details)
           
 void cannotMockFinalClass(java.lang.Class<?> clazz)
           
 void cannotStubVoidMethodWithAReturnValue(java.lang.String methodName)
           
 void cannotStubWithNullThrowable()
           
 void cannotVerifyToString()
           
 void checkedExceptionInvalid(java.lang.Throwable t)
           
 void extraInterfacesAcceptsOnlyInterfaces(java.lang.Class<?> wrongType)
           
 void extraInterfacesCannotContainMockedType(java.lang.Class<?> wrongType)
           
 void extraInterfacesDoesNotAcceptNullParameters()
           
 void extraInterfacesRequiresAtLeastOneInterface()
           
 void fieldInitialisationThrewException(java.lang.reflect.Field field, java.lang.Throwable details)
           
 void incorrectUseOfApi()
           
 void inOrderRequiresFamiliarMock()
           
 void invalidUseOfMatchers(int expectedMatchersCount, int recordedMatchersCount)
           
 void invocationListenerDoesNotAcceptNullParameters()
           
 void invocationListenersRequiresAtLeastOneListener()
           
 void invocationListenerThrewException(InvocationListener listener, java.lang.Throwable listenerThrowable)
           
 void misplacedArgumentMatcher(Location location)
           
 void missingMethodInvocation()
           
 void mockedTypeIsInconsistentWithSpiedInstanceType(java.lang.Class<?> mockedType, java.lang.Object spiedInstance)
           
 void mocksHaveToBePassedToVerifyNoMoreInteractions()
           
 void mocksHaveToBePassedWhenCreatingInOrder()
           
 void moreThanOneAnnotationNotAllowed(java.lang.String fieldName)
           
 void neverWantedButInvoked(PrintableInvocation wanted, Location firstUndesired)
           
 void noArgumentValueWasCaptured()
           
 void noMoreInteractionsWanted(Invocation undesired, java.util.List<VerificationAwareInvocation> invocations)
           
 void noMoreInteractionsWantedInOrder(Invocation undesired)
           
 void notAMockPassedToVerify(java.lang.Class type)
           
 void notAMockPassedToVerifyNoMoreInteractions()
           
 void notAMockPassedToWhenMethod()
           
 void notAMockPassedWhenCreatingInOrder()
           
 void nullPassedToVerify()
           
 void nullPassedToVerifyNoMoreInteractions()
           
 void nullPassedToWhenMethod()
           
 void nullPassedWhenCreatingInOrder()
           
 void onlyVoidMethodsCanBeSetToDoNothing()
           
 void smartNullPointerException(java.lang.String invocation, Location location)
           
 void tooLittleActualInvocations(Discrepancy discrepancy, PrintableInvocation wanted, Location lastActualLocation)
           
 void tooLittleActualInvocationsInOrder(Discrepancy discrepancy, PrintableInvocation wanted, Location lastActualLocation)
           
 void tooManyActualInvocations(int wantedCount, int actualCount, PrintableInvocation wanted, Location firstUndesired)
           
 void tooManyActualInvocationsInOrder(int wantedCount, int actualCount, PrintableInvocation wanted, Location firstUndesired)
           
 void unfinishedStubbing(Location location)
           
 void unfinishedVerificationException(Location location)
           
 void unsupportedCombinationOfAnnotations(java.lang.String undesiredAnnotationOne, java.lang.String undesiredAnnotationTwo)
           
 void wantedAtMostX(int maxNumberOfInvocations, int foundSize)
           
 void wantedButNotInvoked(PrintableInvocation wanted)
           
 void wantedButNotInvoked(PrintableInvocation wanted, java.util.List<? extends PrintableInvocation> invocations)
           
 void wantedButNotInvokedInOrder(PrintableInvocation wanted, PrintableInvocation previous)
           
 void wrongTypeOfReturnValue(java.lang.String expectedType, java.lang.String actualType, java.lang.String methodName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Reporter

public Reporter()
Method Detail

checkedExceptionInvalid

public void checkedExceptionInvalid(java.lang.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(java.lang.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,
                                 int recordedMatchersCount)

argumentsAreDifferent

public void argumentsAreDifferent(java.lang.String wanted,
                                  java.lang.String actual,
                                  Location actualLocation)

wantedButNotInvoked

public void wantedButNotInvoked(PrintableInvocation wanted)

wantedButNotInvoked

public void wantedButNotInvoked(PrintableInvocation wanted,
                                java.util.List<? extends PrintableInvocation> invocations)

wantedButNotInvokedInOrder

public void wantedButNotInvokedInOrder(PrintableInvocation wanted,
                                       PrintableInvocation previous)

tooManyActualInvocations

public void tooManyActualInvocations(int wantedCount,
                                     int actualCount,
                                     PrintableInvocation wanted,
                                     Location firstUndesired)

neverWantedButInvoked

public void neverWantedButInvoked(PrintableInvocation wanted,
                                  Location firstUndesired)

tooManyActualInvocationsInOrder

public void tooManyActualInvocationsInOrder(int wantedCount,
                                            int actualCount,
                                            PrintableInvocation wanted,
                                            Location firstUndesired)

tooLittleActualInvocations

public void tooLittleActualInvocations(Discrepancy discrepancy,
                                       PrintableInvocation wanted,
                                       Location lastActualLocation)

tooLittleActualInvocationsInOrder

public void tooLittleActualInvocationsInOrder(Discrepancy discrepancy,
                                              PrintableInvocation wanted,
                                              Location lastActualLocation)

noMoreInteractionsWanted

public void noMoreInteractionsWanted(Invocation undesired,
                                     java.util.List<VerificationAwareInvocation> invocations)

noMoreInteractionsWantedInOrder

public void noMoreInteractionsWantedInOrder(Invocation undesired)

cannotMockFinalClass

public void cannotMockFinalClass(java.lang.Class<?> clazz)

cannotStubVoidMethodWithAReturnValue

public void cannotStubVoidMethodWithAReturnValue(java.lang.String methodName)

onlyVoidMethodsCanBeSetToDoNothing

public void onlyVoidMethodsCanBeSetToDoNothing()

wrongTypeOfReturnValue

public void wrongTypeOfReturnValue(java.lang.String expectedType,
                                   java.lang.String actualType,
                                   java.lang.String methodName)

wantedAtMostX

public void wantedAtMostX(int maxNumberOfInvocations,
                          int foundSize)

misplacedArgumentMatcher

public void misplacedArgumentMatcher(Location location)

smartNullPointerException

public void smartNullPointerException(java.lang.String invocation,
                                      Location location)

noArgumentValueWasCaptured

public void noArgumentValueWasCaptured()

extraInterfacesDoesNotAcceptNullParameters

public void extraInterfacesDoesNotAcceptNullParameters()

extraInterfacesAcceptsOnlyInterfaces

public void extraInterfacesAcceptsOnlyInterfaces(java.lang.Class<?> wrongType)

extraInterfacesCannotContainMockedType

public void extraInterfacesCannotContainMockedType(java.lang.Class<?> wrongType)

extraInterfacesRequiresAtLeastOneInterface

public void extraInterfacesRequiresAtLeastOneInterface()

mockedTypeIsInconsistentWithSpiedInstanceType

public void mockedTypeIsInconsistentWithSpiedInstanceType(java.lang.Class<?> mockedType,
                                                          java.lang.Object spiedInstance)

cannotCallRealMethodOnInterface

public void cannotCallRealMethodOnInterface()

cannotVerifyToString

public void cannotVerifyToString()

moreThanOneAnnotationNotAllowed

public void moreThanOneAnnotationNotAllowed(java.lang.String fieldName)

unsupportedCombinationOfAnnotations

public void unsupportedCombinationOfAnnotations(java.lang.String undesiredAnnotationOne,
                                                java.lang.String undesiredAnnotationTwo)

cannotInitializeForSpyAnnotation

public void cannotInitializeForSpyAnnotation(java.lang.String fieldName,
                                             java.lang.Exception details)

cannotInitializeForInjectMocksAnnotation

public void cannotInitializeForInjectMocksAnnotation(java.lang.String fieldName,
                                                     java.lang.Exception details)

atMostShouldNotBeUsedWithTimeout

public void atMostShouldNotBeUsedWithTimeout()

fieldInitialisationThrewException

public void fieldInitialisationThrewException(java.lang.reflect.Field field,
                                              java.lang.Throwable details)

invocationListenerDoesNotAcceptNullParameters

public void invocationListenerDoesNotAcceptNullParameters()

invocationListenersRequiresAtLeastOneListener

public void invocationListenersRequiresAtLeastOneListener()

invocationListenerThrewException

public void invocationListenerThrewException(InvocationListener listener,
                                             java.lang.Throwable listenerThrowable)

cannotInjectDependency

public void cannotInjectDependency(java.lang.reflect.Field field,
                                   java.lang.Object matchingMock,
                                   java.lang.Exception details)