capture

inline fun <T : Any> capture(lst: MutableList<T>): T(source)


inline fun <T : Any> capture(lst: CapturingSlot<T>): T(source)

Captures a non-nullable value to a CapturingSlot.

Uses io.mockk.slot to create capturing slot.

See also

for nullable arguments. Example:

interface FileNetwork {
fun download(name: String): File
}

val network = mockk<FileNetwork>()
val slot = slot<String>()

every { network.download(capture(slot)) } returns mockk()

network.download("testfile")
// slot.captured is now "testfile"