espresso-skill
This skill empowers you to create Espresso test scripts for Android applications, streamlining your UI testing automation. Leverage AI-assisted code generation to build robust test cases faster, reducing manual effort and improving test coverage across your Android projects.
espresso-skill enables you to write Espresso tests by guiding you through the core testing pattern: onView(withId(R.id.view_id)).perform(click()).check(matches(isDisplayed())). espresso-skill teaches you to combine ViewMatchers (like withId, withText) to locate UI elements, ViewActions (like click, typeText) to interact with them, and ViewAssertions (like matches, doesNotExist) to verify results. Start by setting up your test class with @RunWith(AndroidJUnit4.class) and @Rule ActivityTestRule, then use onView chains to build your test logic systematically.
AI-generated summary based on this skill's SKILL.md
Install
LambdaTest/agent-skills/espresso-skill · repository language: Python
git clone https://github.com/LambdaTest/agent-skills
cp -r agent-skills/espresso-skill ~/.claude/skills/espresso-skillFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I write Espresso tests for Android?
espresso-skill enables you to write Espresso tests by guiding you through the core testing pattern: onView(withId(R.id.view_id)).perform(click()).check(matches(isDisplayed())). espresso-skill teaches you to combine ViewMatchers (like withId, withText) to locate UI elements, ViewActions (like click, typeText) to interact with them, and ViewAssertions (like matches, doesNotExist) to verify results. Start by setting up your test class with @RunWith(AndroidJUnit4.class) and @Rule ActivityTestRule, then use onView chains to build your test logic systematically.
What are ViewMatchers, ViewActions, and ViewAssertions in Espresso?
espresso-skill breaks down Espresso's three core patterns: ViewMatchers locate elements (withId, withText, withContentDescription, isDisplayed), ViewActions simulate user interactions (click, typeText, scrollTo, swipeLeft, closeSoftKeyboard), and ViewAssertions validate UI state (matches, doesNotExist, check). Together they form the onView(matcher).perform(action).check(assertion) chain. espresso-skill helps you combine these patterns to write fluent, readable test code that mirrors how users interact with your Android app.
How do I set up and configure the Espresso testing environment with Gradle dependencies?
espresso-skill guides you through adding Espresso dependencies to your build.gradle file: androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1', 'androidx.test:runner:1.5.2', and 'androidx.test.ext:junit:1.1.5'. Enable androidTestInstrumentation in your test build variant and ensure your minSdkVersion supports instrumentation testing. espresso-skill helps you configure the test runner in AndroidManifest.xml and set up your project structure so Gradle can compile and execute your Espresso tests on emulators or connected devices.
How do I test Android app UI with Espresso on cloud devices?
espresso-skill supports executing tests on cloud platforms like TestMu AI and LambdaTest by generating test code compatible with their device clouds. After writing your Espresso test suite locally, espresso-skill helps you upload your APK and test APK to the cloud platform, configure device selection (OS version, device model), and trigger test runs. The cloud service executes your Espresso tests on real or virtual devices and returns detailed reports, screenshots, and logs—enabling you to validate your Android UI across multiple device configurations without maintaining physical hardware.
How do I handle async operations and RecyclerView testing in Espresso?
espresso-skill teaches you to manage asynchronous operations using Idling Resources, which pause test execution until background tasks complete. For RecyclerView testing, espresso-skill shows you how to use RecyclerViewActions (like scrollTo, actionOnItem) to navigate large lists and interact with specific items. espresso-skill also covers Intent testing to verify navigation between activities and fragments, and demonstrates best practices like registering custom IdlingResources for network calls or database operations to ensure your tests wait for async work before asserting results.
What are the best practices for Espresso testing on emulators versus real devices?
espresso-skill recommends using emulators for fast local development cycles and CI/CD pipelines, while real devices catch hardware-specific issues and true user behavior. espresso-skill advises running connected Android tests via ./gradlew connectedAndroidTest for local validation, then scaling to cloud device farms for broader coverage. espresso-skill emphasizes writing device-agnostic tests that rely on semantic matchers (withText, withContentDescription) rather than pixel-based assertions, ensuring your Espresso tests remain reliable across different screen sizes, OS versions, and device types.
SKILL.md
rendered from the published skill — quoted content, verbatim
Espresso Automation Skill
You are a senior Android QA engineer specializing in Espresso UI testing.
Step 1 — Execution Target
├─ Mentions "cloud", "TestMu", "LambdaTest", "device farm"?
│ └─ TestMu AI cloud (upload APK + test APK)
│
├─ Mentions "emulator", "local", "connected device"?
│ └─ Local: ./gradlew connectedAndroidTest
│
└─ Default → Local emulator
Core Patterns — Kotlin (Default)
Basic Test
```kotlin @RunWith(AndroidJUnit4::class) class LoginTest {
@get:Rule
val activityRule = ActivityScenarioRule(LoginActivity::class.java)
@Test
fun loginWithValidCredentials() {
// Type
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 4 files
espresso-skill/SKILL.md
espresso-skill/reference/advanced-patterns.md
espresso-skill/reference/cloud-integration.md
espresso-skill/reference/playbook.md