Hi everyone,
This goes back to my earlier post about being able to quickly unit-test functions that execute coroutines.
Especially if these functions have timeouts or delays and you’d like to run each of your tests in milliseconds and not seconds, I wrote a
CoroutineContext
that allows you to do so.
It is very much like the RxJava’s
TestScheduler
and its methods
triggerActions
,
advanceTimeBy
, etc.
It does so by implementing a Coroutine Dispatcher (for speeding up (virtual) time) and a Coroutine Exception Handler (for testing thrown exceptions).
The main
Note that there may be some issues with this implementation. This gist is an initial draft.
The attache Unit-tests all run successfully, but I may have missed something.
If you find an issue with the