Dmytro Danylyk
03/07/2017, 10:06 AMrunBlocking
in test function to wrap my original code which uses launch(CommPool)
?elizarov
03/07/2017, 10:10 AMlaunch(CommonPool)
in your test code with `runBlocking`:
@Test
fun myTest() = runBlocking {
// I can use suspending functions here!
}
There are lots of worked out examples in the guide: https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md#bridging-blocking-and-non-blocking-worldsDmytro Danylyk
03/07/2017, 10:12 AMelizarov
03/07/2017, 8:53 PMrunBlocking<Unit>
Dmytro Danylyk
03/07/2017, 9:07 PMfun sendFeedback(message: String) = launch(MainThread) {
val request = asyncSendFeedback(message)
val response = request.await()
}
elizarov
03/08/2017, 9:21 PMasyncSendFeedback
Dmytro Danylyk
03/09/2017, 9:51 AMsendFeedback
after I got response
I have a lot more logic, so would be cool if I could write test for sendFeedback
elizarov
03/09/2017, 9:53 AMfun sendFeedback(message: String) = launch(MainThread) {
with
suspend fun sendFeedback(message: String) {
This way it becomes a suspending function that is easy to use whenever you need and to test, tooDmytro Danylyk
03/09/2017, 9:54 AM