~/talk

Untangling Coroutine Testing

Talkat Android Makers 2022 · 2022-04-25..04-26· [android, testing]
slides:none on file

Explains concrete migration to kotlinx.coroutines 1.6 testing APIs with runnable examples: use runTest to call suspending functions, inject dispatchers to avoid flakiness, and replace Main with a test dispatcher for viewmodel scope; shows that a 1s delay becomes instantaneous under the test scheduler and how to drive queued coroutines with advanceUntilIdle. Compares queuing standard test dispatcher versus eager unconfined test dispatcher, demos Flow testing (hot sharedFlow, Turbine) and when to cancel collectors.

AI-written summary · about

  1. 0:00Introduction
  2. 3:01Testing suspending functions
  3. 4:51Testing Dispatcher changes
  4. 5:53Testing new coroutines
  5. 9:38Standard TestDispatcher
  6. 13:26UnconfinedTestDispatcher
  7. 15:57Injecting dispatchers
  8. 22:00Keeping track of coroutines
  9. 24:44Handling the Main dispatcher
  10. 28:30Using TestDispatchers in the test
  11. 29:52Using TestDispatchers outside the test
  12. 31:16Creating test objects
  13. 37:19Flows with Turbine
  14. 39:00StateFlows
  15. 41:52Summary
  16. 42:24Resources
  17. 42:52Untangling Coroutine Testing
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.