mockito-kotlin / com.nhaarman.mockitokotlin2 / org.mockito.stubbing.OngoingStubbing

Extensions for org.mockito.stubbing.OngoingStubbing

doAnswer

infix fun <T> OngoingStubbing<T>.doAnswer(answer: Answer<*>): OngoingStubbing<T>

Sets a generic Answer for the method.

infix fun <T> OngoingStubbing<T>.doAnswer(answer: (InvocationOnMock) -> T?): OngoingStubbing<T>

Sets a generic Answer for the method using a lambda.

doReturn

infix fun <T> OngoingStubbing<T>.doReturn(t: T): OngoingStubbing<T>

Sets a return value to be returned when the method is called.

fun <T> OngoingStubbing<T>.doReturn(t: T, vararg ts: T): OngoingStubbing<T>

Sets consecutive return values to be returned when the method is called.

doReturnConsecutively

infix fun <T> OngoingStubbing<T>.doReturnConsecutively(ts: List<T>): OngoingStubbing<T>

Sets consecutive return values to be returned when the method is called.

doThrow

infix fun <T> OngoingStubbing<T>.doThrow(t: Throwable): OngoingStubbing<T>
fun <T> OngoingStubbing<T>.doThrow(t: Throwable, vararg ts: Throwable): OngoingStubbing<T>

Sets Throwable objects to be thrown when the method is called.

infix fun <T> OngoingStubbing<T>.doThrow(t: KClass<out Throwable>): OngoingStubbing<T>

Sets a Throwable type to be thrown when the method is called.

fun <T> OngoingStubbing<T>.doThrow(t: KClass<out Throwable>, vararg ts: KClass<out Throwable>): OngoingStubbing<T>

Sets Throwable classes to be thrown when the method is called.