~/talk

Unit Testing with KotlinFlow

TalkinFrenchat Android Makers by droidcon 2023 · 2023-04-27..04-28· [testing]
links:none on file
slides:none on file

Practical recipes for unit-testing Kotlin Flow: use kotlinx-coroutines-test with runTest (virtual time) to control delays, combine Kluent assertions and Turbine’s test { } API to assert first/last/in-order/no-exception for a three-emission flow, and inject a test dispatcher into StateFlow so hot-vs-cold behavior is reproducible. Demonstrates that StateFlow only exposes the latest value unless collected eagerly and that aligning dispatchers makes tests pass.

AI-written summary · about

  1. 0:00Introduction
  2. 1:07Kotlin Flow recap
  3. 2:54Testing tools
  4. 4:15Cold Flow with Flow API
  5. 5:41Cold Flow with Turbine
  6. 7:06Handling delays in tests
  7. 7:52Switching context with coroutines
  8. 11:03Hot Flows intro
  9. 12:26StateFlow testing issues
  10. 14:56Solving StateFlow issues
  11. 16:23Turbine and concurrent emissions
  12. 17:25Best practices
  13. 18:10Flow API vs Turbine
  14. 20:17Turbine limits for Hot Flows
  15. 21:38Conclusion & 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.