-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Compose] Optimize to test "SharedFlow" execution in Composable with Robolectric #465
Comments
@luongvo This issue seems very opened ended, I can't see how to define clear acceptance criteria here 🤔 Do you have a concrete suggestion for how to resolve this issue? |
@ryan-conway It's still an experiment. However, I found a way to resolve it, so clarifying it in the PR is better 🙏 |
…ecution-in-composable-with-robolectric [#465] [Compose] Optimize to test "SharedFlow" execution in Composable with Robolectric
Why
According to the last implementation of running the Jetpack Compose UI Test with Robolectric, we have to switch the
error
from SharedFlow to StateFlow because we can not make it to be testable withRobolectric
.Using
LaunchedEffect
in Jetpack Compose is a standard best practice, and it's hard to find a replacement forLaunchedEffect
. So in the big picture, if we can not test SharedFlow execution by LaunchedEffect in Composable with Robolectric, we cannot useRobolectric
as our main testing framework for Jetpack Compose to cover all project business logic.Hence, we should research & find a valid way to test SharedFlow execution in Composable with Robolectric without converting it to StateFlow. This also helps to apply using
viewModel.error.collectAsEffect
for error handling instead ofandroid-templates/sample-compose/app/src/main/java/co/nimblehq/sample/compose/ui/screens/home/HomeScreen.kt
Lines 38 to 39 in b9304c7
Who Benefits?
Developers
The text was updated successfully, but these errors were encountered: