Again: What Should I Be Using?
There are a lot of testing options, including some not covered in this chapter.
(yes, this chapter could be much longer…)
There is no “right answer” for testing, so long as you test your app and feel confident that your users will not encounter bugs. That being said, a reasonably popular approach is:
- Focus most of your development efforts on testing things “behind” your UI, such as your viewmodels, repositories, data sources, and similar code. Those things frequently can be implemented as unit tests. Even if they absolutely require Android, and need to be instrumented tests, they may not need you to launch activities or fragments.
- To the greatest extent possible, refactor your application code to move as much logic out of activities and fragments as is practical. In other words, optimize your app code to allow the first bullet to cover that much more of your functionality.
- Resort to Espresso and UI Automator tests where needed, for logic that you simply cannot test by other means. These tend to be the most “flaky” tests. For example, your UI Automator tests might break because the third-party app you are integrating with changed, even though your app logic may still be fine.
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.