testing-setup

Analyze Android build files and create a testing strategy for unit, UI, screenshot, and E2E coverage.

6.6k|388|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/android/skills --skill testing-setup-android
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-setup
Source: https://github.com/android/skills/tree/main/testing/testing-setup
Command: npx skills add https://github.com/android/skills --skill testing-setup-android

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Testing setups for native Android apps often grow ad hoc, causing slow runs, flaky UI tests, missing coverage, and inconsistent screenshot validation across local and device environments.

Core Features & Use Cases

  • Analyze the current testing stack: Detect unit/instrumented/UI/screenshot/E2E frameworks by inspecting build files (for example, DI, JUnit, mocking, Robolectric, Espresso/Compose UI testing, and screenshot tooling).
  • Install and configure test infrastructure: Set up or align DI testing (including test runners and rules), add coverage (for example, Jacoco), and install the right UI/screenshot/E2E frameworks based on the app type (Views, Compose, or hybrid).
  • Create testable code structure: Refactor production dependencies behind fakes and mocks to enable deterministic unit tests and reliable UI behavior testing.
  • Define end-to-end validation: Establish consistent practices for unit testing scope, UI behavior tests, navigation tests, window/configuration simulation, database testing, and a limited set of E2E “big journey” tests, including instrumented screenshot tests when needed.

Quick Start

Use the attached Android project setup to generate a testing strategy that installs the right frameworks and produces a structured plan for unit tests, UI tests, screenshot tests, and end-to-end tests.

Frequently Asked Questions about testing-setup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up a native Android testing strategy from scratch?

To set up a native Android testing strategy, analyze your build files to detect existing frameworks, then install and configure test infrastructure for unit, UI, screenshot, and end-to-end coverage. This includes structuring test sourcesets and refactoring production dependencies behind fakes and mocks.

How does Robolectric work with Espresso for Android UI testing?

Robolectric runs local unit tests while Espresso handles instrumented device-based UI tests. A complete testing setup aligns both frameworks by configuring test runners and rules, enabling reliable UI behavior testing across local and device environments without flaky runs.

What's the best way to configure Compose UI testing and screenshot validation?

The best way to configure Compose UI testing and screenshot validation is to install the right UI and screenshot tooling based on your app type. You establish consistent practices by defining screenshot validation across various scenarios, window sizes, and device configurations.

Can I use dependency injection test rules for instrumented Android tests?

Yes, you can use dependency injection test rules for instrumented tests. Configuring DI testing involves setting up test runners and rules to replace production dependencies with fakes and mocks, ensuring deterministic test execution across unit and end-to-end workflows.

Why are my Android UI tests flaky and missing coverage?

Android UI tests are flaky and miss coverage due to ad hoc testing setups that cause slow runs and inconsistent screenshot validation. Fix this by refactoring code with mocks, aligning DI test harnesses, and structuring test sourcesets for deterministic behavior.

Do I need Jacoco to measure Android end-to-end test coverage?

You need Jacoco to measure Android end-to-end test coverage. Setting up a complete testing strategy includes adding coverage tools like Jacoco to validate a limited set of E2E big journey tests, database testing, and navigation tests.