writing-espresso-tests

Fix flaky Android Espresso tests with correct matchers, actions, and assertions.

303|10|Updated May 15, 2026
One-click install
npx skills add https://github.com/skydoves/android-testing-skills --skill writing-espresso-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-espresso-tests
Source: https://github.com/skydoves/android-testing-skills/tree/main/instrumentation/espresso/writing-espresso-tests
Command: npx skills add https://github.com/skydoves/android-testing-skills --skill writing-espresso-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Espresso View UI tests often fail with missing/ambiguous matchers, ineffective actions, or flaky timing when dialogs, RecyclerView items, intents, or background work are involved.

Core Features & Use Cases

  • Find, act, and assert with the correct Espresso primitives: use onView(matcher).perform(action).check(matches(...)) with the proper matcher/action/assertion catalog for Android Views.
  • Handle the common failure traps: apply inRoot(isDialog()) / inRoot(isPlatformPopup()) for dialogs and popups, select the correct RecyclerView and AdapterView interaction patterns (RecyclerViewActions, onData), and stub/verify intents with Intents lifecycle.
  • Make async work deterministic: register and manage IdlingResource (including correct implementation usage), configure idling timeouts, and avoid Thread.sleep.

Quick Start

Ask the AI to generate an Espresso 3.7.0 instrumentation test for an Android Views screen that clicks a dialog button, interacts with a RecyclerView row, stubs an outbound camera intent, and uses an IdlingResource to wait for non-UI async work.

Frequently Asked Questions about writing-espresso-tests

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

FAQPage Schema
How do I fix Espresso NoMatchingViewException when testing Android dialogs or popups?

Fix flaky Espresso tests by replacing Thread.sleep with an IdlingResource implementation, registering it via IdlingRegistry, and configuring IdlingPolicies timeouts to synchronize non-UI async work deterministically.

Why does my Espresso test throw AmbiguousViewMatcherException on a RecyclerView?

AmbiguousViewMatcherException occurs when multiple views match. Resolve it by using RecyclerViewActions or onData to target specific AdapterView or RecyclerView item interactions instead of generic matchers.

How do I stub an outbound intent in Android Espresso instrumentation tests?

Stub outbound intents in Espresso by initializing the Intents lifecycle using IntentsRule, verifying intent payloads, and releasing resources correctly to avoid test pollution.

What is the best way to wait for background work in Espresso without Thread.sleep?

Wait for background work deterministically by registering an IdlingResource via IdlingRegistry and configuring IdlingPolicies, applying the idle-then-act workflow instead of Thread.sleep.

Does writing Espresso View tests require specific version dependencies?

Writing Espresso View tests requires Espresso 3.7.0 dependencies to correctly access the matcher, action, and assertion catalog needed for Android Views UI instrumentation tests.