Package org.mockito.internal.exceptions
Class Reporter
- java.lang.Object
-
- org.mockito.internal.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).
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
NON_PUBLIC_PARENT
-
Constructor Summary
Constructors Modifier Constructor Description private
Reporter()
-
Method Summary
-
-
-
Field Detail
-
NON_PUBLIC_PARENT
private static final java.lang.String NON_PUBLIC_PARENT
- See Also:
- Constant Field Values
-
-
Method Detail
-
checkedExceptionInvalid
public static MockitoException checkedExceptionInvalid(java.lang.Throwable t)
-
cannotStubWithNullThrowable
public static MockitoException cannotStubWithNullThrowable()
-
unfinishedStubbing
public static MockitoException unfinishedStubbing(Location location)
-
incorrectUseOfApi
public static MockitoException incorrectUseOfApi()
-
missingMethodInvocation
public static MockitoException missingMethodInvocation()
-
unfinishedVerificationException
public static MockitoException unfinishedVerificationException(Location location)
-
notAMockPassedToVerify
public static MockitoException notAMockPassedToVerify(java.lang.Class<?> type)
-
nullPassedToVerify
public static MockitoException nullPassedToVerify()
-
notAMockPassedToWhenMethod
public static MockitoException notAMockPassedToWhenMethod()
-
nullPassedToWhenMethod
public static MockitoException nullPassedToWhenMethod()
-
mocksHaveToBePassedToVerifyNoMoreInteractions
public static MockitoException mocksHaveToBePassedToVerifyNoMoreInteractions()
-
notAMockPassedToVerifyNoMoreInteractions
public static MockitoException notAMockPassedToVerifyNoMoreInteractions()
-
nullPassedToVerifyNoMoreInteractions
public static MockitoException nullPassedToVerifyNoMoreInteractions()
-
notAMockPassedWhenCreatingInOrder
public static MockitoException notAMockPassedWhenCreatingInOrder()
-
nullPassedWhenCreatingInOrder
public static MockitoException nullPassedWhenCreatingInOrder()
-
mocksHaveToBePassedWhenCreatingInOrder
public static MockitoException mocksHaveToBePassedWhenCreatingInOrder()
-
inOrderRequiresFamiliarMock
public static MockitoException inOrderRequiresFamiliarMock()
-
invalidUseOfMatchers
public static MockitoException invalidUseOfMatchers(int expectedMatchersCount, java.util.List<LocalizedMatcher> recordedMatchers)
-
incorrectUseOfAdditionalMatchers
public static MockitoException incorrectUseOfAdditionalMatchers(java.lang.String additionalMatcherName, int expectedSubMatchersCount, java.util.Collection<LocalizedMatcher> matcherStack)
-
stubPassedToVerify
public static MockitoException stubPassedToVerify(java.lang.Object mock)
-
reportNoSubMatchersFound
public static MockitoException reportNoSubMatchersFound(java.lang.String additionalMatcherName)
-
locationsOf
private static java.lang.Object locationsOf(java.util.Collection<LocalizedMatcher> matchers)
-
argumentsAreDifferent
public static java.lang.AssertionError argumentsAreDifferent(java.lang.String wanted, java.util.List<java.lang.String> actualCalls, java.util.List<Location> actualLocations)
-
wantedButNotInvoked
public static MockitoAssertionError wantedButNotInvoked(DescribedInvocation wanted)
-
wantedButNotInvoked
public static MockitoAssertionError wantedButNotInvoked(DescribedInvocation wanted, java.util.List<? extends DescribedInvocation> invocations)
-
createWantedButNotInvokedMessage
private static java.lang.String createWantedButNotInvokedMessage(DescribedInvocation wanted)
-
wantedButNotInvokedInOrder
public static MockitoAssertionError wantedButNotInvokedInOrder(DescribedInvocation wanted, DescribedInvocation previous)
-
tooManyActualInvocations
public static MockitoAssertionError tooManyActualInvocations(int wantedCount, int actualCount, DescribedInvocation wanted, java.util.List<Location> locations)
-
createTooManyInvocationsMessage
private static java.lang.String createTooManyInvocationsMessage(int wantedCount, int actualCount, DescribedInvocation wanted, java.util.List<Location> invocations)
-
neverWantedButInvoked
public static MockitoAssertionError neverWantedButInvoked(DescribedInvocation wanted, java.util.List<Invocation> invocations)
-
tooManyActualInvocationsInOrder
public static MockitoAssertionError tooManyActualInvocationsInOrder(int wantedCount, int actualCount, DescribedInvocation wanted, java.util.List<Location> invocations)
-
createAllLocationsMessage
private static java.lang.String createAllLocationsMessage(java.util.List<Location> locations)
-
createAllLocationsArgsMessage
private static java.lang.String createAllLocationsArgsMessage(java.util.List<Invocation> invocations)
-
createTooFewInvocationsMessage
private static java.lang.String createTooFewInvocationsMessage(Discrepancy discrepancy, DescribedInvocation wanted, java.util.List<Location> locations)
-
tooFewActualInvocations
public static MockitoAssertionError tooFewActualInvocations(Discrepancy discrepancy, DescribedInvocation wanted, java.util.List<Location> allLocations)
-
tooFewActualInvocationsInOrder
public static MockitoAssertionError tooFewActualInvocationsInOrder(Discrepancy discrepancy, DescribedInvocation wanted, java.util.List<Location> locations)
-
noMoreInteractionsWanted
public static MockitoAssertionError noMoreInteractionsWanted(Invocation undesired, java.util.List<VerificationAwareInvocation> invocations)
-
noMoreInteractionsWantedInOrder
public static MockitoAssertionError noMoreInteractionsWantedInOrder(Invocation undesired)
-
noInteractionsWanted
public static MockitoAssertionError noInteractionsWanted(java.lang.Object mock, java.util.List<VerificationAwareInvocation> invocations)
-
cannotMockClass
public static MockitoException cannotMockClass(java.lang.Class<?> clazz, java.lang.String reason)
-
cannotStubVoidMethodWithAReturnValue
public static MockitoException cannotStubVoidMethodWithAReturnValue(java.lang.String methodName)
-
onlyVoidMethodsCanBeSetToDoNothing
public static MockitoException onlyVoidMethodsCanBeSetToDoNothing()
-
wrongTypeOfReturnValue
public static MockitoException wrongTypeOfReturnValue(java.lang.String expectedType, java.lang.String actualType, java.lang.String methodName)
-
wrongTypeReturnedByDefaultAnswer
public static MockitoException wrongTypeReturnedByDefaultAnswer(java.lang.Object mock, java.lang.String expectedType, java.lang.String actualType, java.lang.String methodName)
-
wantedAtMostX
public static MoreThanAllowedActualInvocations wantedAtMostX(int maxNumberOfInvocations, int foundSize)
-
misplacedArgumentMatcher
public static MockitoException misplacedArgumentMatcher(java.util.List<LocalizedMatcher> lastMatchers)
-
smartNullPointerException
public static MockitoException smartNullPointerException(java.lang.String invocation, Location location)
-
noArgumentValueWasCaptured
public static MockitoException noArgumentValueWasCaptured()
-
extraInterfacesDoesNotAcceptNullParameters
public static MockitoException extraInterfacesDoesNotAcceptNullParameters()
-
extraInterfacesAcceptsOnlyInterfaces
public static MockitoException extraInterfacesAcceptsOnlyInterfaces(java.lang.Class<?> wrongType)
-
extraInterfacesCannotContainMockedType
public static MockitoException extraInterfacesCannotContainMockedType(java.lang.Class<?> wrongType)
-
extraInterfacesRequiresAtLeastOneInterface
public static MockitoException extraInterfacesRequiresAtLeastOneInterface()
-
mockedTypeIsInconsistentWithSpiedInstanceType
public static MockitoException mockedTypeIsInconsistentWithSpiedInstanceType(java.lang.Class<?> mockedType, java.lang.Object spiedInstance)
-
cannotCallAbstractRealMethod
public static MockitoException cannotCallAbstractRealMethod()
-
cannotVerifyToString
public static MockitoException cannotVerifyToString()
-
moreThanOneAnnotationNotAllowed
public static MockitoException moreThanOneAnnotationNotAllowed(java.lang.String fieldName)
-
unsupportedCombinationOfAnnotations
public static MockitoException unsupportedCombinationOfAnnotations(java.lang.String undesiredAnnotationOne, java.lang.String undesiredAnnotationTwo)
-
cannotInitializeForSpyAnnotation
public static MockitoException cannotInitializeForSpyAnnotation(java.lang.String fieldName, java.lang.Exception details)
-
cannotInitializeForInjectMocksAnnotation
public static MockitoException cannotInitializeForInjectMocksAnnotation(java.lang.String fieldName, java.lang.String causeMessage)
-
atMostAndNeverShouldNotBeUsedWithTimeout
public static MockitoException atMostAndNeverShouldNotBeUsedWithTimeout()
-
fieldInitialisationThrewException
public static MockitoException fieldInitialisationThrewException(java.lang.reflect.Field field, java.lang.Throwable details)
-
methodDoesNotAcceptParameter
public static MockitoException methodDoesNotAcceptParameter(java.lang.String method, java.lang.String parameter)
-
requiresAtLeastOneListener
public static MockitoException requiresAtLeastOneListener(java.lang.String method)
-
invocationListenerThrewException
public static MockitoException invocationListenerThrewException(InvocationListener listener, java.lang.Throwable listenerThrowable)
-
cannotInjectDependency
public static MockitoException cannotInjectDependency(java.lang.reflect.Field field, java.lang.Object matchingMock, java.lang.Exception details)
-
exceptionCauseMessageIfAvailable
private static java.lang.String exceptionCauseMessageIfAvailable(java.lang.Exception details)
-
mockedTypeIsInconsistentWithDelegatedInstanceType
public static MockitoException mockedTypeIsInconsistentWithDelegatedInstanceType(java.lang.Class<?> mockedType, java.lang.Object delegatedInstance)
-
spyAndDelegateAreMutuallyExclusive
public static MockitoException spyAndDelegateAreMutuallyExclusive()
-
invalidArgumentRangeAtIdentityAnswerCreationTime
public static MockitoException invalidArgumentRangeAtIdentityAnswerCreationTime()
-
invalidArgumentPositionRangeAtInvocationTime
public static MockitoException invalidArgumentPositionRangeAtInvocationTime(InvocationOnMock invocation, boolean willReturnLastParameter, int argumentIndex)
-
possibleArgumentTypesOf
private static java.lang.StringBuilder possibleArgumentTypesOf(InvocationOnMock invocation)
-
wrongTypeOfArgumentToReturn
public static MockitoException wrongTypeOfArgumentToReturn(InvocationOnMock invocation, java.lang.String expectedType, java.lang.Class<?> actualType, int argumentIndex)
-
defaultAnswerDoesNotAcceptNullParameter
public static MockitoException defaultAnswerDoesNotAcceptNullParameter()
-
serializableWontWorkForObjectsThatDontImplementSerializable
public static MockitoException serializableWontWorkForObjectsThatDontImplementSerializable(java.lang.Class<?> classToMock)
-
delegatedMethodHasWrongReturnType
public static MockitoException delegatedMethodHasWrongReturnType(java.lang.reflect.Method mockMethod, java.lang.reflect.Method delegateMethod, java.lang.Object mock, java.lang.Object delegate)
-
delegatedMethodDoesNotExistOnDelegate
public static MockitoException delegatedMethodDoesNotExistOnDelegate(java.lang.reflect.Method mockMethod, java.lang.Object mock, java.lang.Object delegate)
-
usingConstructorWithFancySerializable
public static MockitoException usingConstructorWithFancySerializable(SerializableMode mode)
-
cannotCreateTimerWithNegativeDurationTime
public static MockitoException cannotCreateTimerWithNegativeDurationTime(long durationMillis)
-
notAnException
public static MockitoException notAnException()
-
inlineClassWithoutUnboxImpl
public static MockitoException inlineClassWithoutUnboxImpl(java.lang.Class<?> inlineClass, java.lang.Exception details)
-
formatUnncessaryStubbingException
public static UnnecessaryStubbingException formatUnncessaryStubbingException(java.lang.Class<?> testClass, java.util.Collection<Invocation> unnecessaryStubbings)
-
unncessaryStubbingException
public static void unncessaryStubbingException(java.util.List<Invocation> unused)
-
potentialStubbingProblem
public static void potentialStubbingProblem(Invocation actualInvocation, java.util.Collection<Invocation> argMismatchStubbings)
-
redundantMockitoListener
public static void redundantMockitoListener(java.lang.String listenerType)
-
unfinishedMockingSession
public static void unfinishedMockingSession()
-
missingByteBuddyDependency
public static void missingByteBuddyDependency(java.lang.Throwable t)
-
-