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 TypeMethodDescriptionvoidargumentsAreDifferent(String wanted, String actual, Location actualLocation) voidvoidvoidcannotInitializeForInjectMocksAnnotation(String fieldName, Exception details) voidcannotInitializeForSpyAnnotation(String fieldName, Exception details) voidcannotInjectDependency(Field field, Object matchingMock, Exception details) voidcannotMockFinalClass(Class<?> clazz) voidcannotStubVoidMethodWithAReturnValue(String methodName) voidvoidvoidvoidvoiddelegatedMethodDoesNotExistOnDelegate(Method mockMethod, Object mock, Object delegate) voiddelegatedMethodHasWrongReturnType(Method mockMethod, Method delegateMethod, Object mock, Object delegate) voidextraInterfacesAcceptsOnlyInterfaces(Class<?> wrongType) voidextraInterfacesCannotContainMockedType(Class<?> wrongType) voidvoidvoidfieldInitialisationThrewException(Field field, Throwable details) voidincorrectUseOfAdditionalMatchers(String additionalMatcherName, int expectedSubMatchersCount, Collection<LocalizedMatcher> matcherStack) voidvoidintinvalidArgumentPositionRangeAtInvocationTime(InvocationOnMock invocation, boolean willReturnLastParameter, int argumentIndex) voidvoidinvalidUseOfMatchers(int expectedMatchersCount, List<LocalizedMatcher> recordedMatchers) voidvoidvoidinvocationListenerThrewException(InvocationListener listener, Throwable listenerThrowable) voidmisplacedArgumentMatcher(List<LocalizedMatcher> lastMatchers) voidvoidmockedTypeIsInconsistentWithDelegatedInstanceType(Class mockedType, Object delegatedInstance) voidmockedTypeIsInconsistentWithSpiedInstanceType(Class<?> mockedType, Object spiedInstance) voidvoidvoidmoreThanOneAnnotationNotAllowed(String fieldName) voidneverWantedButInvoked(DescribedInvocation wanted, Location firstUndesired) voidvoidnoMoreInteractionsWanted(Invocation undesired, List<VerificationAwareInvocation> invocations) voidnoMoreInteractionsWantedInOrder(Invocation undesired) voidnotAMockPassedToVerify(Class type) voidvoidvoidvoidvoidvoidvoidvoidvoidreportNoSubMatchersFound(String additionalMatcherName) voidvoidsmartNullPointerException(String invocation, Location location) voidvoidvoidtooLittleActualInvocations(Discrepancy discrepancy, DescribedInvocation wanted, Location lastActualLocation) voidtooLittleActualInvocationsInOrder(Discrepancy discrepancy, DescribedInvocation wanted, Location lastActualLocation) voidtooManyActualInvocations(int wantedCount, int actualCount, DescribedInvocation wanted, Location firstUndesired) voidtooManyActualInvocationsInOrder(int wantedCount, int actualCount, DescribedInvocation wanted, Location firstUndesired) voidunfinishedStubbing(Location location) voidunfinishedVerificationException(Location location) voidunsupportedCombinationOfAnnotations(String undesiredAnnotationOne, String undesiredAnnotationTwo) voidvoidwantedAtMostX(int maxNumberOfInvocations, int foundSize) voidvoidwantedButNotInvoked(DescribedInvocation wanted, List<? extends DescribedInvocation> invocations) voidwantedButNotInvokedInOrder(DescribedInvocation wanted, DescribedInvocation previous) voidwrongTypeOfArgumentToReturn(InvocationOnMock invocation, String expectedType, Class actualType, int argumentIndex) voidwrongTypeOfReturnValue(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
-