doReturnConsecutively

fun <T> OngoingStubbing<T>.doReturnConsecutively(value: T, vararg values: T): OngoingStubbing<T>

Sets values to be returned when the stubbed method/function is being called consecutively. E.g:

    whenever { mock.someMethod() }.doReturnConsecutively(10, 20)

You can specify values to be returned on consecutive invocations. In that case the last value determines the behavior of further consecutive invocations.

This function is an alias for Mockito's OngoingStubbing.thenReturn.

Return

OngoingStubbing object used to stub fluently. Do not create a reference to this returned object.

Parameters

value

return value for the first method/function invocation.

values

return values for the next method/function invocations.


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

Sets values to be returned when the stubbed method/function is being called consecutively. E.g:

    whenever { mock.someMethod() } doReturnConsecutively listOf(10, 20)

The last value in values determines the behavior of further consecutive invocations.

This function is an alias for Mockito's OngoingStubbing.thenReturn.

Return

OngoingStubbing object used to stub fluently. Do not create a reference to this returned object.

Parameters

values

return values for the consecutive method/function invocations.