~/talk

Unit Testing Kotlin Flows

Talkat Chicago Roboto 2021 · on Tuesday, 2021-09-28· [testing, kotlin]
speakerdeck:heyitsmohit
slides:none on file

Unit tests use concrete practices not platitudes: use runBlockingTest to get a test dispatcher that advances virtual time and cancels leftover coroutines, mock upstreams with channels (remember to close them) or with SharedFlow(replay=1) to replay the last event, prefer Turbine for asserting order with expectItem/expectComplete, and test StateFlow conflation, subscriberCount, and whileSubscribed/eager/lazy behaviors so emitted events actually reach consumers.

AI-written summary · about

  1. 0:00Unit testing Kotlin Flows intro
  2. 1:23Kotlin Flows testing foundations
  3. 9:11Libraries for testing Flows
  4. 15:34StateFlow and SharedFlow
  5. 22:38Mocking Flow repositories
  6. 26:51Combining Flows in tests
  7. 33:10Advanced Flow conversions
  8. 37:09Conclusion & Q&A
~/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.