aaverin
08/23/2018, 3:24 PMfun 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
}
Martin Devillers
08/23/2018, 3:31 PMfunToTest
returns a Deferred
, all you have to do in your test is call await()
on it (the test itself should be within runBlocking
).