Testing Coroutines & Flow

TESTING › Unit

Deterministically testing suspend functions, virtual time, dispatcher injection, and Flow emissions.

Interviewers use this to check whether you can write fast, deterministic coroutine tests instead of flaky thread-sleep tests. You are expected to know how runTest and TestScope control virtual time, why production dispatchers must be injected and Dispatchers.Main swapped out, and how to assert Flow emissions cleanly. ViewModel testing with fakes plus a test dispatcher rule is an extremely common live-coding prompt.

What this covers

Study this topic

Further reading