Package org.mockito.exceptions
Class Reporter
java.lang.Object
org.mockito.exceptions.Reporter
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
argumentsAreDifferent
(String wanted, String actual, Location actualLocation) void
void
void
cannotInitializeForInjectMocksAnnotation
(String fieldName, Exception details) void
cannotInitializeForSpyAnnotation
(String fieldName, Exception details) void
cannotInjectDependency
(Field field, Object matchingMock, Exception details) void
cannotMockFinalClass
(Class<?> clazz) void
cannotStubVoidMethodWithAReturnValue
(String methodName) void
void
void
void
void
delegatedMethodDoesNotExistOnDelegate
(Method mockMethod, Object mock, Object delegate) void
delegatedMethodHasWrongReturnType
(Method mockMethod, Method delegateMethod, Object mock, Object delegate) void
extraInterfacesAcceptsOnlyInterfaces
(Class<?> wrongType) void
extraInterfacesCannotContainMockedType
(Class<?> wrongType) void
void
void
fieldInitialisationThrewException
(Field field, Throwable details) void
incorrectUseOfAdditionalMatchers
(String additionalMatcherName, int expectedSubMatchersCount, Collection<LocalizedMatcher> matcherStack) void
void
int
invalidArgumentPositionRangeAtInvocationTime
(InvocationOnMock invocation, boolean willReturnLastParameter, int argumentIndex) void
void
invalidUseOfMatchers
(int expectedMatchersCount, List<LocalizedMatcher> recordedMatchers) void
void
void
invocationListenerThrewException
(InvocationListener listener, Throwable listenerThrowable) void
misplacedArgumentMatcher
(List<LocalizedMatcher> lastMatchers) void
void
mockedTypeIsInconsistentWithDelegatedInstanceType
(Class mockedType, Object delegatedInstance) void
mockedTypeIsInconsistentWithSpiedInstanceType
(Class<?> mockedType, Object spiedInstance) void
void
void
moreThanOneAnnotationNotAllowed
(String fieldName) void
neverWantedButInvoked
(DescribedInvocation wanted, Location firstUndesired) void
void
noMoreInteractionsWanted
(Invocation undesired, List<VerificationAwareInvocation> invocations) void
noMoreInteractionsWantedInOrder
(Invocation undesired) void
notAMockPassedToVerify
(Class type) void
void
void
void
void
void
void
void
void
reportNoSubMatchersFound
(String additionalMatcherName) void
void
smartNullPointerException
(String invocation, Location location) void
void
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
(String undesiredAnnotationOne, String undesiredAnnotationTwo) void
void
wantedAtMostX
(int maxNumberOfInvocations, int foundSize) void
void
wantedButNotInvoked
(DescribedInvocation wanted, List<? extends DescribedInvocation> invocations) void
wantedButNotInvokedInOrder
(DescribedInvocation wanted, DescribedInvocation previous) void
wrongTypeOfArgumentToReturn
(InvocationOnMock invocation, String expectedType, Class actualType, int argumentIndex) void
wrongTypeOfReturnValue
(String expectedType, String actualType, String methodName)
-
Constructor Details
-
Reporter
public Reporter()
-
-
Method Details
-
checkedExceptionInvalid
-
cannotStubWithNullThrowable
public void cannotStubWithNullThrowable() -
unfinishedStubbing
-
incorrectUseOfApi
public void incorrectUseOfApi() -
missingMethodInvocation
public void missingMethodInvocation() -
unfinishedVerificationException
-
notAMockPassedToVerify
-
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
-
argumentsAreDifferent
-
wantedButNotInvoked
-
wantedButNotInvoked
public void wantedButNotInvoked(DescribedInvocation wanted, List<? extends DescribedInvocation> invocations) -
wantedButNotInvokedInOrder
-
tooManyActualInvocations
public void tooManyActualInvocations(int wantedCount, int actualCount, DescribedInvocation wanted, Location firstUndesired) -
neverWantedButInvoked
-
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
-
cannotMockFinalClass
-
cannotStubVoidMethodWithAReturnValue
-
onlyVoidMethodsCanBeSetToDoNothing
public void onlyVoidMethodsCanBeSetToDoNothing() -
wrongTypeOfReturnValue
-
wantedAtMostX
public void wantedAtMostX(int maxNumberOfInvocations, int foundSize) -
misplacedArgumentMatcher
-
smartNullPointerException
-
noArgumentValueWasCaptured
public void noArgumentValueWasCaptured() -
extraInterfacesDoesNotAcceptNullParameters
public void extraInterfacesDoesNotAcceptNullParameters() -
extraInterfacesAcceptsOnlyInterfaces
-
extraInterfacesCannotContainMockedType
-
extraInterfacesRequiresAtLeastOneInterface
public void extraInterfacesRequiresAtLeastOneInterface() -
mockedTypeIsInconsistentWithSpiedInstanceType
-
cannotCallAbstractRealMethod
public void cannotCallAbstractRealMethod() -
cannotVerifyToString
public void cannotVerifyToString() -
moreThanOneAnnotationNotAllowed
-
unsupportedCombinationOfAnnotations
-
cannotInitializeForSpyAnnotation
-
cannotInitializeForInjectMocksAnnotation
-
atMostAndNeverShouldNotBeUsedWithTimeout
public void atMostAndNeverShouldNotBeUsedWithTimeout() -
fieldInitialisationThrewException
-
invocationListenerDoesNotAcceptNullParameters
public void invocationListenerDoesNotAcceptNullParameters() -
invocationListenersRequiresAtLeastOneListener
public void invocationListenersRequiresAtLeastOneListener() -
invocationListenerThrewException
public void invocationListenerThrewException(InvocationListener listener, Throwable listenerThrowable) -
cannotInjectDependency
-
mockedTypeIsInconsistentWithDelegatedInstanceType
-
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
-
delegatedMethodHasWrongReturnType
-
delegatedMethodDoesNotExistOnDelegate
-
usingConstructorWithFancySerializable
-