Error calling Dispatchers.setMain() in unit test
Try adding core as a dependency on your test. It solved the problem for me.
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0")
Turned out issue was I was using older version of kotlinx-coroutines-core
dependency. When I updated to v1.1.0 it worked (thanks @vigit for helping trigger that realisation!)