https://kotlinlang.org logo
p

Paul Woitaschek

12/23/2021, 10:20 AM
What are the recommendations on testing flows? With runTest I always run into a TimeoutCancellationException. For example a very simple reproducer:
Copy code
@Test
  fun myTest() = runTest {
    flow {
      delay(10.milliseconds)
      emit(Unit)
    }.test {
      awaitItem() shouldBe Unit
    }
  }
j

Javier

12/23/2021, 10:21 AM
If you use runBlocking, is it still happening?
p

Paul Woitaschek

12/23/2021, 10:21 AM
Nope
j

Javier

12/23/2021, 10:22 AM
Sadly I saw this issue with runBlockingTest being fixed by runBlocking
I had the hope it was fixed with 1.6.0…
p

Paul Woitaschek

12/23/2021, 10:22 AM
Yep that’s why I’m here 😛
3 Views