~/talk

Untangling Coroutine Testing

Talkat droidcon Berlin 2022 · 2022-07-06..07-08· [testing, kotlin]
slides:none on file

Migrates projects to kotlinx.coroutines 1.6 testing APIs and shows concrete fixes: use runTest to get a TestDispatcher backed by a single TestCoroutineScheduler (never create more than one per test), prefer the standard dispatcher (it queues work) over unconfined (it enters eagerly), control time with advanceUntilIdle / advanceTimeBy / runCurrent, replace the Main dispatcher with setMain/resetMain for ViewModel tests, inject dispatchers to avoid races, and use Turbine for robust Flow testing.

AI-written summary · about

  1. 0:00Introduction to coroutine testing
  2. 1:54New coroutine testing APIs
  3. 3:57Testing suspending functions
  4. 6:25Understanding test scope
  5. 8:11Standard vs unconfined test dispatchers
  6. 14:49Injecting dispatchers in tests
  7. 20:01Handling Android main dispatcher
  8. 24:37Testing flows and state flows
  9. 37:04Summary and resources
~/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.