java.lang.NoClassDefFoundError: Could not initialize class kotlinx.coroutines.experimental.android.HandlerContextKt
j
julioyg
09/12/2018, 8:17 AM
@Joe you might have figured it out by now but you, could inject in the class you launch the coroutine from a class wrapping up the coroutinesContexts, that way you can mock that class for your tests, something like:
Copy code
class MyClass(cc: coroutineContexts) {
fun myMethod() {
launch(cc.ui) {
}
}
}
interface CoroutineContexts {
val ui: CourotineContext
}
class Test {
private val mockedCoroutines = object: CoroutineContexts {
override val ui = Unconfined
}
private val sut = MyClass(mockedCoroutines)
fun test() {
//test
}
}
hope it helps
j
Joe
09/12/2018, 8:19 AM
Yeah, I've looked at that, and if that's necessary, that's fine. I was just surprised the class doesn't seem to exist in the unit tests at all. 😞