writing-espresso-tests

Writes Espresso 3.7.0 instrumentation tests for Android Views with matchers, actions, and assertions.

1|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill writing-espresso-tests-citytexi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: writing-espresso-tests
Source: https://github.com/citytexi/team-yg-pesonal-agent/tree/main/.claude/skills/writing-espresso-tests
Command: npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill writing-espresso-tests-citytexi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reliable Espresso UI tests for Android Views is error-prone: dialog clicks silently fail because RootMatchers.DEFAULT excludes dialogs, RecyclerView rows off-screen cannot be matched, and version-specific gotchas like the missing BottomNavigationViewActions in espresso-contrib 3.7.0 cause confusing compile and runtime failures. ## Core Features & Use Cases - Full matcher/action/assertion catalog: Covers ViewMatchers, ViewActions, ViewAssertions, onData for AdapterView, RecyclerViewActions, and Intents.intended/intending for stubbing camera or share flows. - Gotcha prevention: Encodes the inRoot(isDialog()) requirement, the PickerActions.setDate 1-12 month convention, and the BottomNavigationViewActions absence in 3.7.0 contrib. - IdlingResource guidance: Shows how to register IdlingResources for non-Looper async work and configure IdlingPolicies timeouts instead of using Thread.sleep. - Use Case: A test fails with NoMatchingViewException when clicking an AlertDialog button; the skill diagnoses the RootMatchers.DEFAULT exclusion and rewrites the test with .inRoot(isDialog()). ## Quick Start Ask the assistant to write an Espresso test that clicks a button inside an AlertDialog and verifies a RecyclerView row, using the writing-espresso-tests skill.

Frequently Asked Questions about writing-espresso-tests

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

FAQPage Schema
How do I click a button inside an AlertDialog with Espresso?▼

Espresso dialog clicks require adding .inRoot(isDialog()) to the onView call, because RootMatchers.DEFAULT excludes dialogs, popups, and toasts. Without it, the matcher throws NoMatchingViewException even though the dialog is visible.

How do I click a RecyclerView item in an Espresso test?▼

RecyclerView interactions use RecyclerViewActions from espresso-contrib, such as scrollToPosition, actionOnItemAtPosition, or actionOnItem with a ViewHolder matcher. Matching the row view directly with onView fails when the row is off-screen.

Why does Espresso throw NoMatchingViewException when the view is on screen?▼

NoMatchingViewException means the matcher resolved zero views in the current root. The most common cause is targeting a dialog or popup, which RootMatchers.DEFAULT excludes; add .inRoot(isDialog()) or .inRoot(isPlatformPopup()).

Does espresso-contrib 3.7.0 include BottomNavigationViewActions?▼

No, BottomNavigationViewActions does not exist in espresso-contrib 3.7.0 and importing it fails to compile. Click the menu item view directly using allOf(withId(...), isDescendantOfA(isAssignableFrom(BottomNavigationView::class.java))).

When should I use UiAutomator instead of Espresso?▼

Use UiAutomator when the test crosses app boundaries into system UI, Settings, or the dialer, since Espresso throws InjectEventSecurityException for foreign windows. Espresso is for in-app Android Views; Compose UIs need the Compose testing APIs.

How do I wait for async work in Espresso without Thread.sleep?▼

Register an IdlingResource with IdlingRegistry for non-Looper async work like OkHttp or custom ExecutorServices, and wrap the work in increment/decrement calls from production code. Configure IdlingPolicies timeouts and disable animations via testOptions.animationsDisabled.