vide
val flow = MutableStateFlow(0) val testScope = TestScope() val defaultScope = CoroutineScope(Dispatchers.Default) val values = mutableListOf<Int>() testScope.launch { flow.collect { values.add(it) } } repeat(1000) { n -> defaultScope.launch { flow.value = n } runBlocking { flow.first { it == n } } testScope.testScheduler.runCurrent() assertEquals(values[n], n) }
runCurrent()
defaultScope
// mock update to websocket flow.first { it == n } testedScheduler.runCurrent() // assert ui has updated
A modern programming language that makes developers happier.