for example the method
class SomeClass() {
fun login(listener: (Boolean) -> Unit ) {
do some async logic and then call the listener with the result
}
}
val spy = spyk(SomeClass()) {
val completion = slot<(Boolean) -> Unit>()
//this immediately calls the original login method
every { login(capture(completion)) } answers {
completion.captured.invoke(true)
}
}
trying to stub the login method immediately invokes it.
Do you know how to just stub it and not invoke it?
If we look at the Mockk, maybe relaxed-mock ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.