Join Slack
Powered by
Is it possible to write tests that verify that a s...
# coroutines
c
Casey Brooks
09/25/2020, 3:38 PM
Is it possible to write tests that verify that a suspend method is running on a particular dispatcher? For example, testing that a service call is executed within a
withContext(ioDispatcher)
block (
ioDispatcher
is injected and is a
TestCoroutineDispatcher
in unit tests)
j
Joe
09/25/2020, 4:35 PM
Not sure how safe/future proof these are but you can grab the dispatcher from coroutine context:
https://github.com/trib3/leakycauldron/blob/main/server/src/test/kotlin/com/trib3/server/coroutine/CoroutineInvocationHandlerTest.kt
3
Views
Open in Slack
Previous
Next