explaingit

android/testing-samples

9,295JavaAudience · developerComplexity · 2/5Setup · moderate

TLDR

A collection of small Android example projects from Google's Android team, each demonstrating a specific tool or approach for writing automated tests that check your app works correctly.

Mindmap

mindmap
  root((Android Testing))
    Test types
      Espresso UI tests
      UiAutomator tests
      Runner tests
    Espresso examples
      Basic interactions
      Multiple windows
      Camera simulation
    Setup
      Android Studio
      Gradle build
      Device or emulator
    Extras
      Bazel support
      Lifecycle rules
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Learn how to write Espresso tests that tap buttons, fill text fields, and verify what appears on screen in an Android app.

USE CASE 2

Use UiAutomator examples to test your app from the outside by simulating real user gestures.

USE CASE 3

Find a reference example when adding a specific kind of automated test to your own Android project.

Tech stack

JavaGradleAndroid StudioEspressoUiAutomatorBazel

Getting it running

Difficulty · moderate Time to first run · 30min

Requires Android Studio and either a connected Android device or a running emulator to execute the tests.

Maintained by the official Android team at Google and available for reference and learning, check the repository for the specific open-source license.

In plain English

This repository is a collection of small example projects maintained by the Android team at Google. Each example demonstrates a specific approach to automated testing for Android apps. The goal is to show developers the different tools and frameworks available for checking that their apps work correctly before shipping them to users. The examples cover several testing tools. Espresso is used for testing what users see and interact with on screen, such as buttons, lists, and text inputs. The collection includes more than a dozen Espresso examples, ranging from basic interaction tests to more complex scenarios like handling multiple windows, background tasks, and camera simulations. There is also a UiAutomator example, which tests the app from the outside by simulating real user gestures. Additional examples cover how to run tests using the standard Android test runner and how to apply rules that manage the app lifecycle during testing. To run any of these examples, you need Android Studio or a compatible build environment. The projects use Gradle for building. You can run tests either on a connected physical device or on an emulator. The README includes the exact commands needed. There is also experimental support for Bazel, an alternative build system, though that support is Linux-only and still marked as unofficial. This repository is primarily useful for Android developers who want to learn by example how to write automated tests, or who need a reference when setting up testing in their own projects. Non-technical readers are unlikely to find the content directly useful, as the repository contains only code and instructions aimed at developers.

Copy-paste prompts

Prompt 1
I want to add Espresso UI tests to my Android app. Show me the simplest example from android/testing-samples that tests a button click and checks a text field updates.
Prompt 2
Help me write a UiAutomator test based on android/testing-samples that simulates a user signing in and navigating to the home screen.
Prompt 3
I'm setting up automated testing in a new Android project. Which examples in testing-samples should I look at first for Espresso, the test runner, and lifecycle rules?
Prompt 4
I want to run the Espresso tests from android/testing-samples on a connected Android phone. What Gradle command do I use and what needs to be installed?
Open on GitHub → Explain another repo

← android on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.