Android Test (vi): Android UI Automation test
Release date December 20, 2017 bug Master
Original: https://developer.android.com/training/testing/ui-testing/index.html
User interface (UI) testing ensures that your application meets its functional requirements and meets the high quality standards that users are most likely to adopt successfully.
One way of UI testing is simply to have the human tester perform a set of user actions on the target application and verify that it behaves correctly. However, this manual approach can be time-consuming, tedious, and error-prone. A more effective approach is to write your UI tests so that user actions are performed automatically. Automated methods enable you to run tests quickly and reliably in a repeatable manner.
Note: It is highly recommended that you use Android Studio to build a test application because it provides project settings that are very convenient to include libraries and packages. This assumes that you are using Android Studio.
To automate UI testing using Android Studio, implement your test code in a separate Android Test folder src/androidTest/java
. The Android plugin for Gradle will build the test application based on your test code and then load the test application onto the same device as the target application. In the test code, you can use the UI test framework to simulate user interaction on the target application to perform test tasks that override a specific usage scenario.
In order to test Android applications, these types of UI Automation tests are typically created:
UI testing for a single application: This type of test verifies that the target verifies that the application behaves as expected when the user performs a specific action or enters a specific content in its activity. It allows you to check whether the target application returns the correct UI output in response to user interaction in the application activity. A UI testing framework like espresso allows you to programmatically simulate user actions and test complex in-app user interactions.
UI testing across multiple applications: This type of test verifies the correct behavior between different user applications or between user applications and system applications. For example, you might want to test your camera app to share images correctly with third-party social media applications or the default Android photo app. UI test frameworks that support cross-application interaction, such as UI Automator, allow you to create tests for these scenarios.
This lesson will show you how to build these types of automated tests using the tools and APIs from the Android Test support library. Before you start building tests using these APIs, you must install the Android Test Support library, as described in downloading the Android test support library.
Course
Testing UI for a single app (UI test for individual applications)
- Learn how to test the UI in a single application using the Espresso test framework.
Testing UI for multiple apps (UI tests for multiple applications)
- Learn how to test the UI in multiple applications using the UI Automator test framework.
Android Test (vi): Android UI Automation test