blob: 20422f7b424fd95788a86e392b51981cd6a25b99 [file] [log] [blame]
page.title=Automating User Interface Tests
<div id="tb-wrapper">
<div id="tb">
You should also read
<a href="{@docRoot}tools/testing-support-library/index.html">Testing Support Library</a>
<p>User interface (UI) testing lets you ensure that your app meets its functional requirements
and achieves a high standard of quality such that it is more likely to be successfully adopted by
<p>One approach to UI testing is to simply have a human tester perform a set of user operations on
the target app and verify that it is behaving correctly. However, this manual approach can be
time-consuming, tedious, and error-prone. A more efficient approach is to write your UI
tests such that user actions are performed in an automated way. The automated approach allows
you to run your tests quickly and reliably in a repeatable manner.</p>
<p class="note"><strong>Note: </strong>It is strongly encouraged that you use
<a href="{@docRoot}sdk/installing/studio.html">Android Studio</a> for
building your test apps, because it provides project setup, library inclusion, and packaging
conveniences. This class assumes you are using Android Studio.</p>
<p>To automate UI tests with Android Studio, you implement your test code in a separate
Android test folder ({@code src/androidTest/java}). The
<a href="{@docRoot}tools/building/plugin-for-gradle.html">Android
Plug-in for Gradle</a> builds a test app based on your test code, then loads the test app on the
same device as the target app. In your test code, you can use UI testing frameworks to
simulate user interactions on the target app, in order to perform testing tasks that cover specific
usage scenarios.</p>
<p>For testing Android apps, you typically create these types of automated UI tests:</p>
<li><em>UI tests that span a single app:</em> This type of test verifies that the target app behaves
as expected when a user performs a specific action or enters a specific input in its activities.
It allows you to check that the target app returns the correct UI output in response
to user interactions in the apps activities. UI testing frameworks like Espresso allow you to
programmatically simulate user actions and test complex intra-app user interactions.</li>
<li><em>UI tests that span multiple apps:</em> This type of test verifies the correct behavior of
interactions between different user apps or between user apps and system apps. For example, you
might want to test that your camera app shares images correctly with a 3rd-party social media app,
or with the default Android Photos app. UI testing frameworks that support cross-app interactions,
such as UI Automator, allow you to create tests for such scenarios.</li>
<p>The lessons in this class teach you how to use the tools and APIs in the
<a href="{@docRoot}tools/testing-support-library/index.html">Android Testing Support Library</a>
to build these types of automated tests. Before you begin building tests using these
APIs, you must install the Android Testing Support Library, as described in
<a href="{@docRoot}tools/testing-support-library/index.html#setup">Downloading the Android
Testing Support Library</a>.</p>
<dt><strong><a href="espresso-testing.html">
Testing UI for a Single App</a></strong></dt>
<dd>Learn how to test UI in a single app by using the Espresso testing framework.</dd>
<dt><strong><a href="uiautomator-testing.html">
Testing UI for Multiple Apps</a></strong></dt>
<dd>Learn how to test UI in multiple apps by using the UI Automator testing framework</dd>