Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

testing-setup — Android skill: set up testing from scratch

Analyzes your Android app's testing strategy and installs libraries, infrastructure, and frameworks for unit tests, UI tests, screenshot tests, and end-to-end tests.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add android/skills --skill testing-setup -a claude-code
Open on GitHub

What testing-setup does

The skill performs a systematic audit of your project: checks which dependency injection, unit testing, and mocking frameworks are already installed, looks for Robolectric, determines whether your app is built on Compose or Views, and identifies existing tests (Espresso, Compose Tests, Roborazzi, Paparazzi, UIAutomator). It then generates a Markdown report.

After the audit, the skill installs missing components: a dependency injection framework (Hilt for standard projects, Koin or kotlin-inject for multiplatform), JUnit4 or JUnit5, Robolectric for local UI test runs. For screenshot tests, it picks the tool based on your AGP version: if 9.5.0-alpha03 or higher, it sets up test suites via testOptions; otherwise it uses the legacy com.android.compose.screenshot plugin. For device tests, it adds Dropshots; for e2e, UI Automator.

The skill creates test scaffolding for business logic layers (ViewModels, Repositories, DAOs), sets up fakes for dependencies instead of mocks where faster and more reliable, and prepares tools for unit and screenshot tests based on your existing project stack.

What it helps with

  • Identify which testing frameworks are already installed in the project
  • Choose and install missing libraries for unit and UI tests
  • Configure screenshot testing based on AGP version
  • Create test scaffolding for ViewModels, Repositories, and DAOs
  • Set up fakes for slow or unreliable dependencies

Example prompts for the agent

  • Analyze the testing strategy in my Android project and tell me what's missing
  • Install unit test and UI test frameworks if they're not there
  • Set up Compose screenshot testing for my AGP version

How to install testing-setup

1Skills CLI (Vercel)

npx skills add android/skills --skill testing-setup -a claude-code

2Manually: put the files in place

~/.claude/skills/testing-setup/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/testing-setup/

From the same set5

The whole set →

Similar

dart-add-unit-test dart-lang Writes Dart and Flutter unit tests with package:test: files under test/, mockito mocks when dependencies get in the way, and a rerun loop until the suite is green. Claude Code CX Codex Cursor +1 19,100installs review-and-ship cursor This skill automates code review before shipping: checks for bugs, tests, and intent fit, then commits and opens a PR. Use it to verify your work is ready before merge. Claude Code CX Codex Cursor +1 2,500installs prek j178 Guides agents in configuring and running Git hooks with prek, a Rust alternative to pre-commit. Useful when you need speed, workspace support, or native TOML configuration. Claude Code CX Codex Cursor +1 728installs write-e2e-tests tldraw Guides Playwright E2E testing for tldraw, including UI actions, menus, and canvas shapes. Use it when adding coverage for SDK examples or the tldraw.com client. Claude Code CX Codex Cursor +1 430installs phoenix-evals official [email protected] Build and run evaluators for AI and LLM applications with Phoenix. Use it to investigate failures, evaluate RAG systems, and check model output. GitHub Copilot 1,000installs phoenix-cli official arize-ai A GitHub Copilot skill that drives the Phoenix CLI to pull traces, spans and sessions, then turns what it finds into a failure taxonomy for your LLM app. GitHub Copilot 1,000installs improve-codebase-architecture Matt Pocock This skill scans a codebase for architectural friction, then builds a visual HTML report with refactoring candidates. Use it before a deeper architecture review. Claude Code 1,163,035installs design-taste-frontend Leonxlnx This skill directs the design of public pages and work screens, then checks the result in a browser through screenshots. Use it when an interface feels generic or unfinished. Claude Code CX Codex Cursor +1 673,100installs

Questions about testing-setup

How do I install testing-setup in Claude Code?

Run npx skills add android/skills --skill testing-setup -a claude-code, then open ~/.claude/skills/testing-setup/SKILL.md.

What does testing-setup do?

It first analyzes your current testing infrastructure (which frameworks are already installed), then helps you install missing libraries for unit tests, UI tests, screenshot tests, and e2e tests. It creates test scaffolding for business logic and configures fakes for dependencies.

What AGP version do I need for screenshot tests?

The skill checks your AGP version automatically. If it's 9.5.0-alpha03 or higher, it uses the new test suites format. For older versions, it suggests the legacy com.android.compose.screenshot plugin (marked as deprecated).

Source text

SKILL.md · Apache-2.0
---
name: testing-setup
description: Analyze and create a testing strategy for Android apps - install testing
  libraries, set up test infrastructure, create harnesses for unit tests, UI tests,
  screenshot tests, and end-to-end tests.
license: Complete terms in LICENSE.txt
metadata:
  author: Google LLC
  last-updated: '2026-09-30'
  keywords:
  - android
  - testing
  - ui tests
  - screenshot tests
  - coverage
---

## Step 1: analyze the current testing setup

To understand the testing setup of an existing project, look for these
dependencies in the libs.versions.toml file, or build files:

1. Dependency Injection framework used. For example, Hilt, Koin, Anvil, or vanilla Dagger.
2. Unit (local) testing framework this project uses. For example, JUnit4 or JUnit5.
3. Mocking framework (if any) used for unit tests, and for instrumented and UI tests. For example, Mockito or Mockk.
4. Robolectric. Identify which of these three uses apply:
   1. Used in unit tests to have fakes for platform entities
   2. To run behavior UI tests without a device or emulator. For example, used to run Espresso or Compose tests.
   3. To do screenshot testing with Roborazzi
5. Is the app 100% Compose, Views or hybrid?
6. Behavior UI tests:
   1. Compose Tests (`androidx.compose.ui:ui-test-*`)
   2. Espresso Tests for Views. Check for wrappers such as Kaspresso. Dependencies: `androidx.test.espresso:espresso-core`, `androidx.test:runner`, `androidx.test:rules`.
7. Screenshot tests. Identify which of these types the project uses:
   1. Instrumented (device-based). For example, using Dropshots.
   2. Based on Robolectric, so they run locally. For example, using Roborazzi.
   3. Based on LayoutLib, so they run locally. For example, Paparazzi, or the Compose Preview Screenshot Testing tool.
8. End to end tests (also known as Release Candidate tests) always run on device and use high-level frameworks such as UIAutomator, Appium, or Robotium.
9. Generate a Markdown report with the analysis

## Step 2: Set up Dependency Injection frameworks for testing

If there is no Dependency Injection framework, install one: if it's a
multiplatform application, ask the user whether they want to install Koin, or
kotlin-inject. If it's not multiplatform, install Hilt.

Install the testing dependencies (for example `com.google.dagger:hilt-compiler`
that should be applied with a `kspAndroidTest` configuration).

> [!IMPORTANT]
> **Important:** Always consult the documentation of the applicable framework to learn about testing (for example: [Hilt testing guide](references/android/training/dependency-injection/hilt-testing.md), [Koin Instrumented tests](https://insert-koin.io/docs/reference/koin-android/instrumented-testing)).

For instrumented tests, create and configure (by adding
`testInstrumentationRunner` to the build gradle files) a new test runner and
apply the testing rules required by the framework (for example in Hilt, annotate
your test classes with `@HiltAndroidTest` and apply the `HiltAndroidRule`).
Other frameworks use other mechanisms, consult their documentation.

## Step 3: Install frameworks

Unless otherwise specified, respect the current stack of testing frameworks.

If there are no testing frameworks, and the user didn't specify any preference,
install the following:

- JUnit4 for local and instrumented tests
- Jacoco for test coverage
- For UI tests: if the project has views, Espresso. If it's fully Compose, use the Compose Testing APIs.
- Robolectric to run UI Tests
- Compose Preview Screenshot Testing tool for screenshot tests. Check the
  project's AGP version first, then pick the matching setup and follow it
  strictly:

  - **AGP 9.5.0-alpha03 or higher (recommended):** configure an AGP test suite using `testOptions { screenshotTests.create(...) }`, as described in [Screenshot testing with test suites](references/android/studio/preview/compose-screenshot-testing-with-testsuites.md).
  - **Lower AGP versions:** use the [legacy standalone plugin setup](references/android/studio/preview/compose-screenshot-testing.md) with `com.android.compose.screenshot`, and tell the user it's deprecated. Don't upgrade AGP as part of setting up screenshot tests. Mention that test suites are available on 9.5.0-alpha03 or higher, and leave the upgrade as a separate decision.

  Don't combine both setups in the same module. If the project already uses
  the standalone plugin and its AGP version supports test suites, offer to
  migrate it using the tasks and paths mapping table in
  [Screenshot testing with test suites](references/android/studio/preview/compose-screenshot-testing-with-testsuites.md).
- Dropshots for device screenshot tests

- If a mocking framework is necessary, install Mockk (`io.mockk:mockk`). Do
  not install it unless it is clearly necessary.

If instrumented screenshot tests are requested, install Dropshots.

If end-to-end testing is requested, install UI Automator.

## Step 4: Refactor and create fakes for testing

### **Refactor for unit tests**

In the next sections you'll be asked to create tests. If you have dependencies
on Android framework classes, or entities that are not part of the codebase:

- First, use a fake. If it doesn't exist, create an interface for the class
  and a "Default" implementation with the existing code. Add the Fake version
  to the test sourceset (test or androidTest).

- If not possible to use a fake (example: no access to the class or
  interface), mock the dependencies.

### **Refactor for UI tests**

If you need to fake components to make testing easier and faster and more
reliable, replace slow and problematic dependencies with fakes. Use runtime
fakes using the Dependency Injection framework installed to:

- **Simulate** different scenarios with the user (wrong credentials or a password reset flow), with a server (no connection, server down, or bad JSON from the server) or with a platform component (insufficient permissions, no disk space, no front camera available)
- **Improve** speed and reliability (replacing a database with an in-memory database, replacing a repository with an in-memory fake to avoid hitting the network)

## Step 5: Unit testing

Create a task to add or review unit tests in every file that contains business
logic (ViewModels, Repositories, and database-related classes such as DAOs).
Don't create unit tests for Activities, Compose layouts, or dependency injection
configuration files.

## Step 6: UI testing

Espresso or Compose UI tests live in the `test` sourceset because they will be
run with Robolectric. If instrumented (emulator or device) tests are requested,
put them in the `androidTest` sourceset.

## Step 7: Test databases

If the database is using SQLite (through a library such as Room or SQLDelight),
create instrumented tests using an in-memory database to make sure that they
work with the SQLite engine on device.

## Step 8: Screenshot tests

Regardless of the framework used, screenshot tests focus on two types of tests:

- Screen-level screenshot tests, where each screen is tested in nine different sizes, combining compact, medium and expanded widths (400, 610, 900 dp) and heights (400, 500 and 1000 dp).
- Screen-level variations. Add a mobile (400x500) screenshot of:
  - All the alternative themes, if used.
  - Font scale set to 1.5.
- Component-level screenshot tests, where each component is tested in different themes and font scales.

Behavior isn't tested with screenshots, but do test different common scenarios
if their UIs change a lot depending on the state. For example, test loading
screens by injecting a loading state to the UI or simulating it with a fake.

## Step 9: UI Behavior tests

Test the UI logic using behavior tests, which ensures that the UIs react as
expected when different states are passed, and when user actions are performed.

### **Compose UI behavior tests**

- Use the ComposeTestRule with a `ComponentActivity` to access resources such as strings.
- Always match with semantic matchers first. If the matcher is too complicated to write (using more than three matchers to find a single element), use `testTag`.
- Always verify state restoration.

### **Views (XML) UI behavior tests**

Use Espresso to match views and interact with them.

## Step 10: Navigation tests

Create a test suite to verify navigation logic. Include:

- Back handling
- Deeplinks
- Special patterns like "exit through home" with multiple backstacks.

## Step 11: Simulate different window sizes and settings

For Compose layouts, use `DeviceConfigurationOverride` described in "[UI testing
common patterns](references/android/develop/ui/compose/testing/common-patterns.md)" to simulate different window sizes, font scales

## Step 12: End-to-end tests

Create a low number (about 5% of all tests) of end-to-end tests that cover big
user journeys. Use Compose Test APIs or Espresso for that. If you have to access
platform features such as notifications or system UI, use UI Automator.

If you need to take screenshots of the app running in a device, use
[Dropshots](https://raw.githubusercontent.com/dropbox/dropshots/refs/heads/main/README.md). You need a device for screenshot tests when verifying
interaction with the system UI (examples: edge-to-edge rendering, notifications,
picture-in-picture)

### Step 13: Instrumented Screenshot tests

Install the `com.dropbox.dropshots` plugin in the module and a `Dropshots()`
JUnit Rule. Create a new instrumented screenshot test for one of the app's
features.

### Step 14: Install jacoco

Install jacoco for local testing code coverage.

- Add the `jacoco` plugin to each module that contains tests.

## Final touches

- Ask whether to document the findings of the analysis and the changes applied
  to the testing strategy. If the user agrees:

  - If there is an AGENTS.md file present in the project, update it with any
    changes you've made to the testing strategy.

  - If there is no AGENTS.md file, create a new file (docs/testing.md) with
    a description of the testing strategy, including the commands needed to
    run every type of test and where the screenshot reference files live.
    Also create a new AGENTS.md file in the root and create a link to
    docs/testing.md.

© Google LLC · Apache-2.0 · android/skills

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor