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

Finish documentation of SharedTests and AndroidTests in ::app module #14

Closed
fknives opened this issue Sep 18, 2021 · 3 comments · Fixed by #70
Closed

Finish documentation of SharedTests and AndroidTests in ::app module #14

fknives opened this issue Sep 18, 2021 · 3 comments · Fixed by #70
Labels
documentation Improvements or additions to documentation Priority
Milestone

Comments

@fknives
Copy link
Owner

fknives commented Sep 18, 2021

No description provided.

@fknives fknives added documentation Improvements or additions to documentation Priority labels Sep 18, 2021
@fknives fknives added this to the Version 1 milestone Jan 5, 2022
@fknives
Copy link
Owner Author

fknives commented Jan 14, 2022

Don't forget to mention the issue with ProgressBars with Espresso: namely that progressbar and other infinite loading indicators will make the MainThread not Idle, thus Espresso actions lock up,
Reference:
https://stackoverflow.com/questions/30469240/java-lang-runtimeexception-could-not-launch-intent-for-ui-with-indeterminate
https://stackoverflow.com/questions/35186902/testing-progress-bar-on-android-with-espresso

All original links provided in reference are outdated sadly

@fknives
Copy link
Owner Author

fknives commented Jan 20, 2022

Additional notes to add to SharedTests:

  • dialogs are not handled the same way by Robolectric. Can't test them with Espresso, ShadowDialog.getLatestDialog() can be used. So the solution is to have a DialogVerification class, to interact with dialogs, which uses Espresso on AndroidTests and ShadowDialog in Robolectric Test
  • Crashlytics and other elements can be turned off, by using a custom Application class.
  • Hilt requires a HiltTestApplication to test with.
  • In Hilt FragmentScenarios are not supported, so to test Fragments, one way is to use a HiltActivity with EntryPoint and manage the ActivityScenario's lifecycle.
  • mockwebserver.url()/.start() can throw NetworkOnMainThreadException exception on Android Device, one solution is to wrap it into a BackgroundThread execution, example: runBlocking { withContext(Dispatcher.IO) { mockwebserver.url("/") } }. reference = NetworkOnMainThreadException square/okhttp#3184
  • resource access can be different between androidTest and RoboletricTest, can be mitigated by a config which uses assets in AndroidTest and resources in Robolectric.
  • Advancing mainDispatcher should happen on the MainThread, so if livedata observers are executed, then it won't crash because TestRunnerThread is being used to touch them, one easy way is activityScenario.onActivity{ which runs on main thread.

@fknives fknives changed the title Finish documentation of SharedTests in ::app module Finish documentation of SharedTests and AndroidTests in ::app module Jan 28, 2022
@fknives
Copy link
Owner Author

fknives commented Feb 3, 2022

Mention also the Pointer location developer options when dealing with touch events

@fknives fknives linked a pull request Apr 6, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation Priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant