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

[#354] [Compose] 2/2: Add sample UI test with Robolectric #399

Merged
merged 7 commits into from
Feb 22, 2023

Conversation

luongvo
Copy link
Member

@luongvo luongvo commented Feb 4, 2023

#354

What happened 👀

  • Add a sample for writing UI test with Robolectric as unit test instead of an Instrument test.
  • Set up running UI tests with Robolectric as default for the template project.

Insight 📝

  • Add org.robolectric:robolectric dependency in testImplementation.
  • Add androidx.compose.ui:ui-test-junit4 for Compose UI test and androidx.test:rules for permission granting.
  • Clone HomeScreenTest from androidTest folder into test with replacing @RunWith(AndroidJUnit4::class) by @RunWith(RobolectricTestRunner::class). Now our HomeScreenTest can run with Robolectric as unit test instead of an Instrument test ✅

Proof Of Work 📹

All unit tests passed ✅

image

Kover now can report code coverage for HomeScreen

image

@luongvo luongvo added this to the 3.17.0 milestone Feb 4, 2023
@luongvo luongvo self-assigned this Feb 4, 2023
@luongvo luongvo changed the base branch from develop to feature/354-set-up-ui-tests February 4, 2023 17:47
@luongvo luongvo changed the title [#354] [Compose] Add sample UI test with Robolectric [#354] [Compose] 2/2: Add sample UI test with Robolectric Feb 4, 2023
@luongvo luongvo linked an issue Feb 4, 2023 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Feb 4, 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: 29.95%

Coverage of Modified Files:

File Coverage
BaseViewModel.kt 0.00%

Modified Files Not Found In Coverage Report:

HomeScreen.kt
HomeScreenTest.kt
HomeScreenTest.kt
HomeScreenTest.kt
HomeViewModelTest.kt
HomeViewModelTest.kt
Versions.kt
Versions.kt
build.gradle.kts
build.gradle.kts
robolectric.properties
robolectric.properties

Codebase cunningly covered by count Shroud 🧛

Kover report for template-compose:

🧛 Template - Compose Unit Tests Code Coverage: 58.59%

Coverage of Modified Files:

File Coverage
BaseViewModel.kt 97.62%
HomeScreen.kt 50.46%

Modified Files Not Found In Coverage Report:

HomeScreenTest.kt
HomeScreenTest.kt
HomeScreenTest.kt
HomeViewModelTest.kt
HomeViewModelTest.kt
Versions.kt
Versions.kt
build.gradle.kts
build.gradle.kts
robolectric.properties
robolectric.properties

Codebase cunningly covered by count Shroud 🧛

Generated by 🚫 Danger

@kaungkhantsoe
Copy link
Contributor

kaungkhantsoe commented Feb 7, 2023

@luongvo Everything is okay with current implementation style. There is a concern I have mentioned in this comment. There is a workaround for it but it doesn't fix the issue for pull to refresh UI test. May I know what is your idea about the problem? 🙇

@luongvo luongvo force-pushed the feature/354-add-sample-ui-test-with-robolectric branch from dc95667 to 576ca89 Compare February 8, 2023 04:57
@luongvo
Copy link
Member Author

luongvo commented Feb 8, 2023

@luongvo Everything is okay with current implementation style. There is a concern I have mentioned in this comment. There is a workaround for it but it doesn't fix the issue for pull to refresh UI test. May I know what is your idea about the problem? 🙇

@kaungkhantsoe I will have reply in that PR 👌

Copy link
Contributor

@thiennguyen0196 thiennguyen0196 left a comment

Choose a reason for hiding this comment

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

LGTM

@luongvo luongvo force-pushed the feature/354-add-sample-ui-test-with-robolectric branch from 5f3f9c0 to 367fe6a Compare February 13, 2023 04:34
@luongvo luongvo force-pushed the feature/354-add-sample-ui-test-with-robolectric branch from bce5422 to 337e96f Compare February 13, 2023 10:28
@luongvo luongvo force-pushed the feature/354-add-sample-ui-test-with-robolectric branch from 337e96f to ac96acf Compare February 14, 2023 09:08
Base automatically changed from feature/354-set-up-ui-tests to develop February 16, 2023 02:20
@luongvo luongvo requested a review from Wadeewee February 16, 2023 03:37
Copy link
Collaborator

@ryan-conway ryan-conway left a comment

Choose a reason for hiding this comment

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

Just one question, the rest LGTM 🙏🏻

@luongvo luongvo requested a review from ryan-conway February 16, 2023 04:26
Copy link
Collaborator

@ryan-conway ryan-conway left a comment

Choose a reason for hiding this comment

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

👌🏻

Copy link
Member

@chornerman chornerman 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 5a037e8 into develop Feb 22, 2023
@ryan-conway ryan-conway deleted the feature/354-add-sample-ui-test-with-robolectric branch February 22, 2023 10:53
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] Setup UI and Integration tests
7 participants