Skip to content
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

Conversation

luongvo
Copy link
Member

@luongvo luongvo commented May 19, 2023

#465

What happened 👀

Insight 📝

  • To assert a Toast from a SharedFlow execution in the ViewModel's init block with Robolectric,

  • To simplify the preparation step, move initViewModel() into initComposable() to initialize ViewModel with necessary mocking before rendering the Composable.

Proof Of Work 📹

  • Template
    image

  • Sample
    image

@github-actions
Copy link

github-actions bot commented May 19, 2023

3 Warnings
⚠️ Uh oh! BaseViewModel.kt is under 95% coverage!
⚠️ Uh oh! Your project is under 80% coverage!
⚠️ Uh oh! HomeScreen.kt is under 95% coverage!

Kover report for template-xml:

🧛 Template - XML Unit Tests Code Coverage: 34.51%

Coverage of Modified Files:

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

@luongvo luongvo force-pushed the feature/465-test-shared-flow-execution-in-composable-with-robolectric branch 2 times, most recently from 53c1605 to 34c7d9a Compare May 19, 2023 06:48
@luongvo luongvo marked this pull request as ready for review May 19, 2023 06:59
@luongvo luongvo marked this pull request as draft May 19, 2023 07:04
@luongvo luongvo marked this pull request as ready for review May 19, 2023 08:28
@luongvo luongvo added this to the 3.20.0 milestone May 19, 2023
Copy link

@doannimble doannimble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 🚀

@ryan-conway ryan-conway merged commit 1d2e496 into develop May 25, 2023
@ryan-conway ryan-conway deleted the feature/465-test-shared-flow-execution-in-composable-with-robolectric branch May 25, 2023 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Compose] Optimize to test "SharedFlow" execution in Composable with Robolectric
5 participants