I started using `runBlockingTest` and am now getti...
# coroutines
j
I started using
runBlockingTest
and am now getting:
java.lang.IllegalStateException: This job has not completed yet
Is there some nice way to figure out which job has not been completed? Or do I need to find that out myself?
a
can you share the method to test? you might need to inject a testdispatcher or just use runBlocking{}
j
I'm trying to figure out where I'm leaking some coroutines here: https://github.com/aPureBase/KGraphQL/blob/4a69f9ff4cdfb844fc6f4f0480bef2667fa060e9/kgraphql/src/test/kotlin/com/apurebase/kgraphql/DataLoaderTest.kt#L504 This is a function that creates a lot of coroutines recursively, and I want to be 100% sure that there are no coroutines lost somewhere, but it seems like there currently is.
If injecting a testdispatcher will help I will do that 🙂
z
Are you naming your coroutines? If you're doing that, then you could make an exception breakpoint that matches that message and probably inspect the coroutine context around where it's getting thrown.
👍 1
j
Thanks I will try naming all my coroutines and see if I figure out how to pinpoint the problem. I've never named any coroutines before. Is this the correct way to do that?
Copy code
launch(CoroutineName("this-coroutine-name")) {
    println("Hello World")
}
👌 1
z
Yep!