# android/testing-samples

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/android-testing-samples).**

9,297 stars · 3,638 forks · Java · Apache-2.0

## Links

- GitHub: https://github.com/android/testing-samples
- awesome-repositories: https://awesome-repositories.com/repository/android-testing-samples.md

## Description

This is a collection of sample projects that demonstrate how to write automated tests for Android applications. The samples cover a range of testing techniques, including simulating user interactions with the Espresso framework, verifying navigation and inter-component communication through intent interception, and managing activity, intent, and service lifecycles using reusable test rules.

The repository provides concrete implementations for testing across multiple application windows, capturing screenshots during test execution for visual verification, and synchronizing test assertions with background work to prevent flaky results. It also includes examples of parameterized test execution that runs the same test logic with multiple input values, as well as techniques for interacting with and verifying content inside embedded WebViews.

The samples are organized to illustrate how to control and inspect UI elements across different applications on a device, and how to organize tests into reusable suites for comprehensive coverage. The documentation and code examples are structured to serve as reference implementations for Android testing frameworks and automated UI and unit test patterns.

## Tags

### Testing & Quality Assurance

- [Android UI Testing](https://awesome-repositories.com/f/testing-quality-assurance/android-ui-testing.md) — Provides sample implementations for writing automated UI tests that simulate user interactions on Android.
- [Testing Samples](https://awesome-repositories.com/f/testing-quality-assurance/android-ui-testing/testing-samples.md) — Serves as a collection of sample projects demonstrating various Android testing frameworks and techniques.
- [Espresso UI Testing](https://awesome-repositories.com/f/testing-quality-assurance/android-ui-testing/espresso-ui-testing.md) — Provides sample code showing how to use Espresso to simulate user interactions and verify on-screen element states in Android apps.
- [View Hierarchy Matchers](https://awesome-repositories.com/f/testing-quality-assurance/assertion-matchers/view-hierarchy-matchers.md) — Matches on-screen elements by traversing the view hierarchy and applying declarative matchers for state verification.
- [Test Background Work Synchronization](https://awesome-repositories.com/f/testing-quality-assurance/background-job-testing/test-background-work-synchronization.md) — Pauses test execution until background tasks finish to prevent flaky assertions. ([source](https://cdn.jsdelivr.net/gh/android/testing-samples@main/README.md))
- [Android Parameterized Test Execution](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-utilities-assertions/test-lifecycle-execution-control/test-parameterization/android-parameterized-test-execution.md) — Provides sample implementations for running Android tests with multiple input values and organizing them into reusable suites.
- [Espresso Framework Testing](https://awesome-repositories.com/f/testing-quality-assurance/native-mobile-app-automation/android-emulator-test-automation/espresso-framework-testing.md) — Uses the Espresso framework to perform UI actions and assertions in Android tests for reliable app behavior.
- [Android](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/component-testing/lifecycle-testing/android.md) — Demonstrates controlling activity, intent, and service lifecycles in Android tests with reusable rules.
- [Android Lifecycle Test Rules](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/component-testing/lifecycle-testing/android-lifecycle-test-rules.md) — Controls activity, intent, or service lifecycle within test cases using reusable Android test rules. ([source](https://cdn.jsdelivr.net/gh/android/testing-samples@main/README.md))
- [Espresso UI Testing](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/ui/ui-test-engines/espresso-ui-testing.md) — Simulates user actions and checks on-screen element states using the Espresso framework for Android. ([source](https://cdn.jsdelivr.net/gh/android/testing-samples@main/README.md))
- [Test Idling Resources](https://awesome-repositories.com/f/testing-quality-assurance/testing-infrastructure-management/test-orchestration/worker-process-management/worker-lifecycle-management/idle-resource-cleanup/test-idling-resources.md) — Synchronizes test assertions with background work by polling registered resources until they report idle.
- [Multi-Window Testing](https://awesome-repositories.com/f/testing-quality-assurance/android-ui-testing/multi-window-testing.md) — Provides sample implementations for directing test actions to UI elements across multiple application windows on Android.
- [Android](https://awesome-repositories.com/f/testing-quality-assurance/automation-interaction-tools/screenshot-capture/android.md) — Captures frame buffer screenshots at test checkpoints for visual verification of Android UI state.
- [Test](https://awesome-repositories.com/f/testing-quality-assurance/automation-interaction-tools/screenshot-capture/test.md) — Takes and saves screenshots of the current screen during test execution for visual verification. ([source](https://cdn.jsdelivr.net/gh/android/testing-samples@main/README.md))
- [Parameterized Test Runners](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/execution-and-infrastructure/test-execution-runners/test-suite-runners/parameterized-test-runners.md) — Runs the same test logic with multiple input values by iterating over annotated data sources.
- [Parameterized Test Suites](https://awesome-repositories.com/f/testing-quality-assurance/unit-testing-frameworks/test-suite-organization/parameterized-test-suites.md) — Executes tests with multiple input values and organizes them into reusable test suites. ([source](https://cdn.jsdelivr.net/gh/android/testing-samples@main/README.md))

### Mobile Development

- [Test Rule Wrappers](https://awesome-repositories.com/f/mobile-development/android-activity-lifecycle-management/test-rule-wrappers.md) — Provides reusable test rules that automatically launch and tear down activities for each test method.
- [Android Intent Integrations](https://awesome-repositories.com/f/mobile-development/android-intent-integrations.md) — Provides sample implementations for intercepting and verifying intents to test navigation and inter-app communication in Android.
- [Intent Stubbing](https://awesome-repositories.com/f/mobile-development/intent-based-navigation/intent-stubbing.md) — Stubs intents to verify navigation and inter-component communication without launching external activities.
- [Intent Verification Testing](https://awesome-repositories.com/f/mobile-development/intent-based-navigation/intent-verification-testing.md) — Captures and stubs intents in Android tests to verify navigation and communication between app components.

### Operating Systems & Systems Programming

- [Intent Interception for Testing](https://awesome-repositories.com/f/operating-systems-systems-programming/intent-redirection/intent-interception-for-testing.md) — Captures outgoing intents or stubs incoming ones to verify navigation and inter-component communication in tests. ([source](https://cdn.jsdelivr.net/gh/android/testing-samples@main/README.md))

### Development Tools & Productivity

- [WebView Test Automation](https://awesome-repositories.com/f/development-tools-productivity/webview-automation/webview-test-automation.md) — Performs actions and checks content inside embedded web pages during test execution. ([source](https://cdn.jsdelivr.net/gh/android/testing-samples@main/README.md))

### User Interface & Experience

- [Android Cross-App UI Control](https://awesome-repositories.com/f/user-interface-experience/cross-platform-ui-automations/android-cross-app-ui-control.md) — Controls and inspects UI elements across multiple applications on an Android device. ([source](https://cdn.jsdelivr.net/gh/android/testing-samples@main/README.md))
- [WebView DOM Injection](https://awesome-repositories.com/f/user-interface-experience/webview-interface-customizations/javascript-injections/webview-dom-injection.md) — Injects JavaScript into embedded WebViews to query and manipulate DOM elements during test execution.
- [Android Multi-Window UI Testing](https://awesome-repositories.com/f/user-interface-experience/window-management/multi-window-controllers/android-multi-window-ui-testing.md) — Directs test actions to UI elements across multiple application windows on Android devices. ([source](https://cdn.jsdelivr.net/gh/android/testing-samples@main/README.md))

### Web Development

- [Android Multi-Window Focus Routing](https://awesome-repositories.com/f/web-development/headless-browser-controllers/window-configurations/window-focus-switching/android-multi-window-focus-routing.md) — Routes UI interactions to the correct window by resolving display and window token identifiers during tests.
