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

streetsofboston

02/01/2019, 4:25 AM
@Sam Maybe this works, given a CoroutineScope:
scope.coroutineContext[ContinuationInterceptor]
s

Sam

02/01/2019, 5:42 AM
Thx, the type when used with default dispatcher is kotlinx.coroutines.scheduling.DefaultScheduler, which happens to be internal. How can i check to see if it is default? internal object DefaultScheduler
I'm trying to write a test to verify if the component is using the passed dispatcher
r

rrva

02/01/2019, 5:49 AM
send in a mock of the dispatcher and verify that it's being used?
s

streetsofboston

02/01/2019, 11:57 AM
Or add your custom
Element
to the CoroutineScope's `coroutineContext`and test for that Element's presence in your test-code.
s

Sam

02/01/2019, 2:17 PM
custom Element is fine but nothing stops in that layer from ignoring the provided dispatcher or override with a different dispatcher, and the test would pass instead of failing
s

streetsofboston

02/01/2019, 2:28 PM
I see. Yep, then inserting a ‘mock’ Dispatcher and checking if it is still there is the best option.
s

Sam

02/01/2019, 2:46 PM
yeah, mock is the only way