Lukasz Kalnik
07/19/2023, 3:40 PMDispatcher
instance used inside a Spec
? I'm testing Android ViewModel and for this need to replace the Main
dispatcher inside viewModelScope
using Dispatchers.setMain()
.Sam
07/19/2023, 3:57 PMval dispatcher = coroutineContext[CoroutineDispatcher]
, just as in normal code. If you have set coroutineTestScope = true
for your test suite, the dispatcher will be a TestDispatcher
— see https://kotest.io/docs/framework/coroutines/test-coroutine-dispatcher.htmlLukasz Kalnik
07/19/2023, 4:24 PM