https://kotlinlang.org logo
Title
g

George Theocharis

06/17/2020, 4:00 PM
Hello all! Today came up with this weird exception. I have a custom presenter scope which i use to launch coroutines on. On java presenters an async method is exposed that get the scope as a parameter in order to be able to launch it in a kotlin file instead. Today I was writing some tests using mockk doing something like this:
every { presenter.scope } returns TestCoroutineScope()
and I was trying to verify in order some calls including the invokeAsync I mentioned. The exception I am getting is an abstract method error on newCoroutineContext that i cannot think of a solution. The code works, the test not. If you also debug it also works correctly until its time to return to the java side. Sorry for the wall its a bit complicated and haven’t seen it previously. Ps i am using dispatchers.setMain and the coroutines test dependency.
z

Zach Klippenstein (he/him) [MOD]

06/17/2020, 4:04 PM
What's the exception?
g

George Theocharis

06/17/2020, 4:08 PM
java.lang.AbstractMethodError at kotlinx.coroutines.CoroutineContextKt.newCoroutineContext I dont have the entire stacktrace now but its not that helpful either.
Solved it for anyone interested: Had to wrap the test in
testCoroutineDispatcher.runBlockingTest
and had to pass the scope like this invokeAsync(this@runBlockingTest)
👏 1