every

fun <T> every(stubBlock: MockKMatcherScope.() -> T): MockKStubScope<T, T>(source)

Starts a block of stubbing. Part of DSL.

Used to define what behaviour is going to be mocked.

Example:

interface Navigator {
val currentLocation: String
}

val navigator = mockk<Navigator>()
every { navigator.currentLocation } returns "Home"

println(navigator.currentLocation) // prints "Home"

See also

Coroutine version.