~/talk

Unit Testing Kotlin Channels & Flows

Talkat Android Summit 2020 · 2020-10-08..10-09· [testing, android]
speakerdeck:heyitsmohit
slides:none on file

Shows how to test real coroutine code: using runBlockingTest and TestCoroutineDispatcher to advance virtual time for delays, using turbine to assert individual Flow emissions and expectComplete, stubbing a Flow to throw to verify retry logic and using advanceTimeBy to exercise two retries, wrapping errors in a Result type instead of expectError, and testing ViewModel state by setting the main dispatcher and observing mutableStateFlow’s conflation (suggests mutableSharedFlow for non‑conflated events).

AI-written summary · about

  1. 0:00Start
  2. 0:43Use Cases for Testing Flows
  3. 1:45Simple Implementation
  4. 2:43Test the Simple Flow
  5. 14:16Design Pattern for Injecting Your Dispatchers
  6. 16:21Test Errors
  7. 17:30Result Type
  8. 19:19Do Tests Retry
  9. 27:29Immutable State Flow
  10. 28:00How Immutable State Flow Works
  11. 28:20Launch in View Model Scope
~/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.