CallRecorder

Records values, such as arguments passed to a faked dependency, in the order calls arrive.

Recording never suspends, so it is safe from synchronous callbacks and from any thread. Finish the operation under test before inspecting values; calls racing on different threads are ordered by whichever records first.

val recorder = CallRecorder<String>()
val client = FakeClient(onRequest = recorder::record)

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val count: Int

The number of recorded calls.

Functions

Link copied to clipboard
fun lastValue(): T?

Returns the most recently recorded value.

Link copied to clipboard
fun record(value: T)

Appends value to the call history.

Link copied to clipboard
fun reset()

Clears the history; pending waitForCalls calls observe the new history.

Link copied to clipboard
fun values(): List<T>

Returns a snapshot of every recorded value in arrival order.

Link copied to clipboard
suspend fun waitForCalls(count: Int, timeout: Duration = 2.seconds): List<T>

Waits in real time until at least count calls have been recorded.