What is the difference between do ```TestCoroutine...
# coroutines
p
What is the difference between do
Copy code
TestCoroutineScope.runBlockingTest{}
And
Copy code
TestCoroutineDispatcher.runBlockingTest{}
I see some people use them, and others just put
runBlockingText{}
without any dispatcher nor coroutineScope, is there any difference?
g
Scope also includes uncaught exception handler
but it also uses TestCoroutineDispatcher
runBlockingTest is just a top level coroutine which uses TestCoroutineScope, so it convinince method
p
Still unclear for me Andrey, you mean that if I use testCoroutineScope.runBlockingTest{..} the exceptions wouldn't be caught? Because I saw other coleagues are using both ways and I'm trying to figure it out what's better or efficient. Also I'm used to do it without them, like
Copy code
runBlockingTest {
 my test here
}
g
just open runBlockingTest implementation, it creates TestCoroutineScope under the hood
also it checks that all jobs started on this scope are finished
the exceptions wouldn’t be caught
no, it’s just records all uncaught exceptions and print stacktrace, just gives a bit more info on crash
actually if you open implementation, all those functions actually do the same, just on different receivers
Top level runBlockingTest is just a good building block, doesn’t require creation of coroutine scope
p
That's what I wanted to know 🙂
runBlockingTest
creates everything for you, but I guess they did it like this to ensure, it was running on a TestDispatcher 🤷
g
but
runBlockingTest
always run on TestDispatchter until you override it