https://kotlinlang.org logo
#coroutines
Title
# coroutines
a

aaverin

08/23/2018, 3:24 PM
pseudocode:
Copy code
fun funToTest() = async {
   registerDevice()
   //... and lots of extra logic here
}

private suspend fun registerDevice() = suspendCoroutine {
 // handle complex callback logic and do it.resume(data) for suspendCoroutine
}
m

Martin Devillers

08/23/2018, 3:31 PM
Since your
funToTest
returns a
Deferred
, all you have to do in your test is call
await()
on it (the test itself should be within
runBlocking
).
2 Views