coroutinedispatcher
11/18/2020, 10:31 PMSharedFlow
but I am getting an IllegalStateException: This job has not completed yet
. It’s basically pretty easy because I commented out the rest of the code for now:
fun registerNewUser(email: String, password: String, hint: String) {
viewModelScope.launch { _state.emit(State.Loading) }
// commented out for the moment just to make sure it's not the rest of the code that is failing the test
}
And the test:
@Test
fun `starting registration process will set the state immediately to loading`() =
runBlockingTest(testCoroutineDispatcher) {
registerViewModel.registerNewUser("anyEmail", "anyPassword", "anyHint")
~ assertEquals(registerViewModel.state.first(), RegisterViewModel.State.Loading)
}
Versions:
coroutines: "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1",
coroutines_android : "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1",
coroutines_test: "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.1"
Probably doing something wrong, but not sure what. Any ideas/input?SharedFlow
👀StateFlow
just checking the _state.value
would work