org.mockito.exceptions
Class Reporter
java.lang.Object
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).
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 |
incorrectUseOfAdditionalMatchers(java.lang.String additionalMatcherName,
int expectedSubMatchersCount,
java.util.Collection<LocalizedMatcher> matcherStack)
|
void |
incorrectUseOfApi()
|
void |
inOrderRequiresFamiliarMock()
|
int |
invalidArgumentPositionRangeAtInvocationTime(InvocationOnMock invocation,
boolean willReturnLastParameter,
int argumentIndex)
|
void |
invalidArgumentRangeAtIdentityAnswerCreationTime()
|
void |
invalidUseOfMatchers(int expectedMatchersCount,
java.util.List<LocalizedMatcher> recordedMatchers)
|
void |
invocationListenerDoesNotAcceptNullParameters()
|
void |
invocationListenersRequiresAtLeastOneListener()
|
void |
invocationListenerThrewException(InvocationListener listener,
java.lang.Throwable listenerThrowable)
|
void |
misplacedArgumentMatcher(java.util.List<LocalizedMatcher> lastMatchers)
|
void |
missingMethodInvocation()
|
void |
mockedTypeIsInconsistentWithDelegatedInstanceType(java.lang.Class mockedType,
java.lang.Object delegatedInstance)
|
void |
mockedTypeIsInconsistentWithSpiedInstanceType(java.lang.Class<?> mockedType,
java.lang.Object spiedInstance)
|
void |
mocksHaveToBePassedToVerifyNoMoreInteractions()
|
void |
mocksHaveToBePassedWhenCreatingInOrder()
|
void |
moreThanOneAnnotationNotAllowed(java.lang.String fieldName)
|
void |
neverWantedButInvoked(DescribedInvocation 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 |
reportNoSubMatchersFound(java.lang.String additionalMatcherName)
|
void |
smartNullPointerException(java.lang.String invocation,
Location location)
|
void |
spyAndDelegateAreMutuallyExclusive()
|
void |
tooLittleActualInvocations(Discrepancy discrepancy,
DescribedInvocation wanted,
Location lastActualLocation)
|
void |
tooLittleActualInvocationsInOrder(Discrepancy discrepancy,
DescribedInvocation wanted,
Location lastActualLocation)
|
void |
tooManyActualInvocations(int wantedCount,
int actualCount,
DescribedInvocation wanted,
Location firstUndesired)
|
void |
tooManyActualInvocationsInOrder(int wantedCount,
int actualCount,
DescribedInvocation 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(DescribedInvocation wanted)
|
void |
wantedButNotInvoked(DescribedInvocation wanted,
java.util.List<? extends DescribedInvocation> invocations)
|
void |
wantedButNotInvokedInOrder(DescribedInvocation wanted,
DescribedInvocation previous)
|
void |
wrongTypeOfArgumentToReturn(InvocationOnMock invocation,
java.lang.String expectedType,
java.lang.Class actualType,
int argumentIndex)
|
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 |
Reporter
public Reporter()
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,
java.util.List<LocalizedMatcher> recordedMatchers)
incorrectUseOfAdditionalMatchers
public void incorrectUseOfAdditionalMatchers(java.lang.String additionalMatcherName,
int expectedSubMatchersCount,
java.util.Collection<LocalizedMatcher> matcherStack)
reportNoSubMatchersFound
public void reportNoSubMatchersFound(java.lang.String additionalMatcherName)
argumentsAreDifferent
public void argumentsAreDifferent(java.lang.String wanted,
java.lang.String actual,
Location actualLocation)
wantedButNotInvoked
public void wantedButNotInvoked(DescribedInvocation wanted)
wantedButNotInvoked
public void wantedButNotInvoked(DescribedInvocation wanted,
java.util.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,
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(java.util.List<LocalizedMatcher> lastMatchers)
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)
mockedTypeIsInconsistentWithDelegatedInstanceType
public void mockedTypeIsInconsistentWithDelegatedInstanceType(java.lang.Class mockedType,
java.lang.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,
java.lang.String expectedType,
java.lang.Class actualType,
int argumentIndex)