Thoughts on using runBlocking in tests instead of ...
# coroutines
c
Thoughts on using runBlocking in tests instead of runTest? Seems like everything runs fine with runBlocking?
r
runTest
is more useful when you want to control time, or launch coroutines on a background scope (e.g. stateIn/shareIn) that get cleaned up automatically.
☝🏻 1
☝️ 2
☝🏾 1
k
runTest also works on JS and includes built-in timeout functionality.
o
Or even better – but biased opinion: The test framework should provide you with sensible options and figure it out for you.
g
runTest also has built it timeout, which is very useful
j
The default unconfined dispatcher is a bit annoying when you want to test all states without caring about doing some manual delays to avoid conflating, probably the problems you are finding with
runTest
and are solved with
runBlocking
can be fixed changing the dispatcher
👍 1