-
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
[#465] [Compose] Optimize to test "SharedFlow" execution in Composable with Robolectric #466
[#465] [Compose] Optimize to test "SharedFlow" execution in Composable with Robolectric #466
Conversation
…hout switching to StateFlow
Kover report for template-xml:🧛 Template - XML Unit Tests Code Coverage:
|
File | Coverage |
---|---|
BaseViewModel.kt |
0.00% |
Modified Files Not Found In Coverage Report:
BaseScreenTest.kt
BaseScreenTest.kt
CoroutineTestRule.kt
CoroutineTestRule.kt
HomeScreen.kt
HomeScreenTest.kt
HomeScreenTest.kt
Versions.kt
Versions.kt
build.gradle.kts
build.gradle.kts
Codebase cunningly covered by count Shroud 🧛
Kover report for template-compose:
🧛 Template - Compose Unit Tests Code Coverage: 60.74%
Coverage of Modified Files:
File | Coverage |
---|---|
BaseViewModel.kt |
71.69% |
HomeScreen.kt |
54.07% |
Modified Files Not Found In Coverage Report:
BaseScreenTest.kt
BaseScreenTest.kt
CoroutineTestRule.kt
CoroutineTestRule.kt
HomeScreenTest.kt
HomeScreenTest.kt
Versions.kt
Versions.kt
build.gradle.kts
build.gradle.kts
Codebase cunningly covered by count Shroud 🧛
Generated by 🚫 Danger
53c1605
to
34c7d9a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 🚀
#465
What happened 👀
viewModel.error.collectAsEffect
for error handling.BaseScreenTest
as a helper to simplify the test logic for Compose.Insight 📝
To assert a Toast from a SharedFlow execution in the ViewModel's
init
block with Robolectric,coroutinesRule.testDispatcher = StandardTestDispatcher()
composeRule.waitForIdle()
to wait until the Compose view is readyadvanceUntilIdle()
to trigger the execution before asserting.To simplify the preparation step, move
initViewModel()
intoinitComposable()
to initialize ViewModel with necessary mocking before rendering the Composable.Proof Of Work 📹
Template

Sample
