to test a Controller use Controller.state:
Controller
Controller.state
private val testScope = TestScope(UnconfinedTestDispatcher()) @Test fun testController() { // given val sut = // create Controller from testScope // when sut.action(Action.SetCounter(3)) testScope.advanceTimeBy(5000) // then assertEquals(3, sut.state.value.counterValue) }
when not using a Flow testing framework, one can also use val states: List<State> = controller.state.toList() to verify states
Flow
val states: List<State> = controller.state.toList()
val testScope = TestScope() val sut = testScope.createController<Action, Mutation, State>( initialState = State(value = 0), ... ) testScope.advanceTimeBy(delayTimeMillis = 5000)
There was an error while loading. Please reload this page.