The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.
Yet another approach for testing Android applications is UI Automator. This is designed for integration testing, both how your app components integrate with one another (e.g., activities starting activities) and how your app components integrate with the rest of a device, including other applications.
In early 2015, Google released version 2.0 of the UI Automator framework. This update ties UI Automator into the same instrumentation testing engine that is used for JUnit4 testing. This also makes it possible to run UI Automator tests through Android Studio and Gradle for Android, which previously had been difficult.
This chapter assumes that you have read the chapter on JUnit4.
UI Automator, as the name suggests, automates UIs. It simulates user input, in the form of tapping on items and the like. It does so without modifying your process’ contents. Tests run by UI Automator are implemented in JUnit, and those tests have limited access to the widgets inside of a UI. Such access not only allows for directing simulated user input (e.g., “click the OK button”), but also for asserting that various test conditions are true (e.g., “does the list have five rows?”). In this respect, UI Automator behaves like traditional Android JUnit testing.
The preview of this section was fed to a gremlin, after midnight.
The preview of this section took that left turn at Albuquerque.
The preview of this section is out seeking fame and fortune as the Dread Pirate Roberts.
The preview of this section was whisked away by a shark-infested tornado.
The preview of this section apparently resembled a Pokémon.
The preview of this section was abducted by space aliens.