prudhvi reddy
08/04/2024, 6:54 PMcatch
operator?
This test case fails with a crash.
Whereas if i don't use catch
operator but used try-catch
the test is as expectedprudhvi reddy
08/04/2024, 6:54 PMFrancesc
08/04/2024, 7:18 PMoverride fun invoke(): Flow<int> = flow {
throw Exception()
}
Francesc
08/04/2024, 7:22 PMephemient
08/04/2024, 8:38 PMprudhvi reddy
08/05/2024, 2:41 AMFrancesc
08/05/2024, 3:45 AMprudhvi reddy
08/05/2024, 3:47 AMtry catch
instead of using catch
operator
fun test() {
try {
mainUseCase.invoke()
.flowOn(dispatcher.default())
.onEach {
//No op
}
.launchIn(viewModelScope)
} catch (e: Exception) {
isError = true
}
}
Yeah i'm testing if an exception occurs and gets handled as expectedFrancesc
08/05/2024, 3:51 AMephemient
08/05/2024, 7:01 PMprudhvi reddy
08/06/2024, 6:03 AM