Is it possible to write tests that verify that a s...
# coroutines
c
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
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