I've got a test with `runBlockingTest` function. F...
# coroutines
m
I've got a test with
runBlockingTest
function. From this test I'm running code that launches coroutine from
MainScope
object that is suppose to have
TestCoroutineDispatcher
but I can't seem to run
delay
function inside that coroutine because I'm getting
UncompletedCoroutinesError
exception. Is my test setup wrong or I just can't test a code that has
delay
functions? I don't really need that delay but was just wondering why it doesn't work, I thought that runBlocking and TestCoroutineDispatcher will take care of such cases
I think I've got a problem with junit5 extension (rule in junit4), I'm running the code to replace the dispatcher but that doesn't have desired effect..
d
do you have some code to show?
l
Which
runBlockingTest
are you using? You may be running into this issue https://craigrussell.io/2019/11/unit-testing-coroutine-suspend-functions-using-testcoroutinedispatcher/
👍 1
m
very nice article, thanks James!
@Dennis that's the code that fails
oh, it does work correctly with
TestCoroutineDispatcher.runBlockingTest
but now I can't use my test extension from junit5 because it's not like junit4 rule where you're defining it as a class member
I can use it in an old fashion way with a class member thanks to
@RegisterExtension
field, now everything works, thanks!