class ArgumentCaptorHolder4<out A, out B, out C, out D> |
|
class ArgumentCaptorHolder5<out A, out B, out C, out D, out E> |
|
class InOrderOnType<T> : InOrder |
|
class KArgumentCaptor<out T> |
|
class KStubbing<out T> |
|
class UseConstructor |
|
class VerifyScope<out T> |
class MockitoKotlinException : RuntimeException |
fun after(millis: Long): VerificationAfterDelay
Allows verifying over a given period. It causes a verify to wait for a specified period of time for a desired interaction rather than failing immediately if has not already happened. May be useful for testing in concurrent conditions. |
|
fun <T : Any> any(): T
Matches any object, excluding nulls. |
|
fun <T> anyArray(): Array<T>
Matches any array of type T. |
|
fun <T : Any> anyOrNull(): T
Matches anything, including nulls. |
|
fun <T : Any> anyVararg(): T
Matches any vararg object, including nulls. |
|
fun <T : Any> argForWhich(predicate: T.() -> Boolean): T
Alias for argThat. |
|
fun <T : Any> argThat(predicate: T.() -> Boolean): T
Creates a custom argument matcher.
fun <T : Any> argThat(matcher: ArgumentMatcher<T>): T
Registers a custom ArgumentMatcher. The original Mockito function registers the matcher and returns null, here the required type is returned. |
|
fun <T : Any> argWhere(predicate: (T) -> Boolean): T
Creates a custom argument matcher.
|
|
fun <T : Any> argumentCaptor(): KArgumentCaptor<T>
Creates a KArgumentCaptor for given type. fun <A : Any, B : Any> argumentCaptor(a: KClass<A> = A::class, b: KClass<B> = B::class): Pair<KArgumentCaptor<A>, KArgumentCaptor<B>>
Creates 2 KArgumentCaptors for given types. fun <A : Any, B : Any, C : Any> argumentCaptor(a: KClass<A> = A::class, b: KClass<B> = B::class, c: KClass<C> = C::class): Triple<KArgumentCaptor<A>, KArgumentCaptor<B>, KArgumentCaptor<C>>
Creates 3 KArgumentCaptors for given types. fun <A : Any, B : Any, C : Any, D : Any> argumentCaptor(a: KClass<A> = A::class, b: KClass<B> = B::class, c: KClass<C> = C::class, d: KClass<D> = D::class): ArgumentCaptorHolder4<KArgumentCaptor<A>, KArgumentCaptor<B>, KArgumentCaptor<C>, KArgumentCaptor<D>>fun <A : Any, B : Any, C : Any, D : Any, E : Any> argumentCaptor(a: KClass<A> = A::class, b: KClass<B> = B::class, c: KClass<C> = C::class, d: KClass<D> = D::class, e: KClass<E> = E::class): ArgumentCaptorHolder5<KArgumentCaptor<A>, KArgumentCaptor<B>, KArgumentCaptor<C>, KArgumentCaptor<D>, KArgumentCaptor<E>>
Creates 4 KArgumentCaptors for given types. fun <T : Any> argumentCaptor(f: KArgumentCaptor<T>.() -> Unit): KArgumentCaptor<T>
Creates a KArgumentCaptor for given type, taking in a lambda to allow fast verification. |
|
fun atLeast(numInvocations: Int): VerificationMode
Allows at-least-x verification. |
|
fun atLeastOnce(): VerificationMode
Allows at-least-once verification. |
|
fun atMost(maxNumberOfInvocations: Int): VerificationMode
Allows at-most-x verification. |
|
fun calls(wantedNumberOfInvocations: Int): VerificationMode
Allows non-greedy verification in order. |
|
fun <T : Any> capture(captor: ArgumentCaptor<T>): T
Alias for ArgumentCaptor.capture. |
|
fun <T : Any> check(predicate: (T) -> Unit): T
For usage with verification only. |
|
fun <T> clearInvocations(vararg mocks: T): Unit
Use this method in order to only clear invocations, when stubbing is non-trivial. |
|
fun description(description: String): VerificationMode
Adds a description to be printed if verification fails. |
|
fun <T> doAnswer(answer: (InvocationOnMock) -> T?): Stubber |
|
fun doCallRealMethod(): Stubber |
|
fun doNothing(): Stubber |
|
fun doReturn(value: Any?): Stubberfun doReturn(toBeReturned: Any?, vararg toBeReturnedNext: Any?): Stubber |
|
fun doThrow(toBeThrown: KClass<out Throwable>): Stubberfun doThrow(vararg toBeThrown: Throwable): Stubber |
|
fun <T> eq(value: T): T
Object argument that is equal to the given value. |
|
fun <T> given(methodCall: T): BDDMyOngoingStubbing<T>
Alias for BDDMockito.given. fun <T> given(methodCall: () -> T): BDDMyOngoingStubbing<T>
Alias for BDDMockito.given with a lambda. |
|
fun ignoreStubs(vararg mocks: Any): Array<out Any>
Ignores stubbed methods of given mocks for the sake of verification. |
|
fun inOrder(vararg mocks: Any): InOrder
Creates InOrder object that allows verifying mocks in order. fun inOrder(vararg mocks: Any, evaluation: InOrder.() -> Unit): Unit
Creates InOrder object that allows verifying mocks in order. Accepts a lambda to allow easy evaluation. fun <T> T.inOrder(block: InOrderOnType<T>.() -> Any): Unit
Allows InOrder verification for a single mocked instance: |
|
fun <T : Any> isA(): T
Argument that implements the given class. |
|
fun <T : Any> isNotNull(): T?
Not |
|
fun <T : Any> isNull(): T?
|
|
fun <T : Any> mock(extraInterfaces: Array<out KClass<out Any>>? = null, name: String? = null, spiedInstance: Any? = null, defaultAnswer: Answer<Any>? = null, serializable: Boolean = false, serializableMode: SerializableMode? = null, verboseLogging: Boolean = false, invocationListeners: Array<InvocationListener>? = null, stubOnly: Boolean = false, useConstructor: UseConstructor? = null, outerInstance: Any? = null, lenient: Boolean = false): T
Creates a mock for T. fun <T : Any> mock(extraInterfaces: Array<out KClass<out Any>>? = null, name: String? = null, spiedInstance: Any? = null, defaultAnswer: Answer<Any>? = null, serializable: Boolean = false, serializableMode: SerializableMode? = null, verboseLogging: Boolean = false, invocationListeners: Array<InvocationListener>? = null, stubOnly: Boolean = false, useConstructor: UseConstructor? = null, outerInstance: Any? = null, lenient: Boolean = false, stubbing: KStubbing<T>.(T) -> Unit): T
Creates a mock for T, allowing for immediate stubbing. fun <T : Any> fun <T : Any> fun <T : Any> |
|
fun mockingDetails(toInspect: Any): MockingDetails |
|
fun never(): VerificationMode
Alias for times with parameter |
|
fun <T : Any> notNull(): T?
Not |
|
fun <T : Any> nullableArgumentCaptor(): KArgumentCaptor<T?>
Creates a KArgumentCaptor for given nullable type. fun <T : Any> nullableArgumentCaptor(f: KArgumentCaptor<T?>.() -> Unit): KArgumentCaptor<T?>
Creates a KArgumentCaptor for given nullable type, taking in a lambda to allow fast verification. |
|
fun only(): VerificationMode
Allows checking if given method was the only one invoked. |
|
fun <T : Any> refEq(value: T, vararg excludeFields: String): T
Object argument that is reflection-equal to the given value with support for excluding selected fields from a class. |
|
fun <T> reset(vararg mocks: T): Unit |
|
fun <T> same(value: T): T
Object argument that is the same as the given value. |
|
fun <T : Any> spy(): T
Creates a spy of the real object. The spy calls real methods unless they are stubbed. fun <T : Any> spy(stubbing: KStubbing<T>.(T) -> Unit): Tfun <T> spy(value: T, stubbing: KStubbing<T>.(T) -> Unit): T
Creates a spy of the real object, allowing for immediate stubbing. The spy calls real methods unless they are stubbed. fun <T> spy(value: T): T
Creates a spy of the real object. The spy calls real methods unless they are stubbed. |
|
fun <T : Any> T.stub(stubbing: KStubbing<T>.(T) -> Unit): T |
|
fun <T> stubbing(mock: T, stubbing: KStubbing<T>.(T) -> Unit): Unit |
|
fun <T> then(mock: T): Then<T>
Alias for BDDMockito.then. |
|
fun timeout(millis: Long): VerificationWithTimeout
Allows verifying with timeout. It causes a verify to wait for a specified period of time for a desired interaction rather than fails immediately if has not already happened. May be useful for testing in concurrent conditions. |
|
fun times(numInvocations: Int): VerificationMode
Allows verifying exact number of invocations. |
|
fun validateMockitoUsage(): Unit |
|
fun <T> verify(mock: T): T
Verifies certain behavior happened once. fun <T> verify(mock: T, mode: VerificationMode): T
Verifies certain behavior happened at least once / exact number of times / never. fun <T> verify(mock: T, block: VerifyScope<T>.() -> Unit): Unit
Verify multiple calls on mock Supports an easier to read style of |
|
fun <T> verifyBlocking(mock: T, f: suspend T.() -> Unit): Unit
Verifies certain suspending behavior happened once. fun <T> verifyBlocking(mock: T, mode: VerificationMode, f: suspend T.() -> Unit): Unit
Verifies certain behavior happened at least once / exact number of times / never. |
|
fun <T> verifyNoMoreInteractions(vararg mocks: T): Unit
Checks if any of given mocks has any unverified interaction. |
|
fun verifyZeroInteractions(vararg mocks: Any): Unit
Verifies that no interactions happened on given mocks beyond the previously verified interactions. |
|
fun <T> whenever(methodCall: T): OngoingStubbing<T>
Enables stubbing methods. Use it when you want the mock to return particular value when particular method is called. |
|
fun withSettings(extraInterfaces: Array<out KClass<out Any>>? = null, name: String? = null, spiedInstance: Any? = null, defaultAnswer: Answer<Any>? = null, serializable: Boolean = false, serializableMode: SerializableMode? = null, verboseLogging: Boolean = false, invocationListeners: Array<InvocationListener>? = null, stubOnly: Boolean = false, useConstructor: UseConstructor? = null, outerInstance: Any? = null, lenient: Boolean = false): MockSettings
Allows mock creation with additional mock settings. See MockSettings. |