onBlocking

fun <T : Any, R> KStubbing<T>.onBlocking(methodCall: suspend T.() -> R): OngoingStubbing<R>

Deprecated

Use on { methodCall } instead

Enables stubbing methods/function calls. In case of Kotlin function calls, these can be either synchronous or suspendable function calls.

Simply put: "on a call to the x function then return y".

Examples:

    stubbing(mock) {
onBlocking { mock.someFunction() } doReturn 10
}

This is a deprecated alias for on. Please use on instead.

Return

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

Parameters

methodCall

(regular or suspendable) lambda, wrapping the function call to be stubbed.