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