Is there a testing library other than turbine, which would work with MutableStateFlow, i.e. sideffecting type of code? (toList hangs)
in rx it would looks like this
Copy code
@Test fun `doSomething should move state to FINAL`() {
val viewModel = createViewModel(initialState = State.INITIAL)
val testSubscriber = viewModel.state.test()
viewModel.doSomething()
testSubscriber.assertValues(State.INITIAL, State.FINAL)
}
Yeah and Turbine supports MutableStateFlow's just fine. Basically if it emits, Turbine captures it.
u
ursus
03/30/2021, 7:50 AM
Thx guys, but i mentioned other than turbine. I'm just like the way rx did it better. Is there something wrong with the sample below?
e
Erik
03/30/2021, 3:07 PM
What I like about turbine is that it allows me to easily test
setup
assert initial state
call function under test
assert state(s), event(s), error(s)
(call more stuff and assert more)
final assertions
cleanup
instead of
setup
calls
assert all the things without knowing the order of emissions w.r.t. calls
final assertions
cleanup