espresso-suite
БесплатноБез исполняемых скриптовНе проверенUse whenever an Android app needs UI tests in Google's Espresso: onView with perform and check, automatic synchronization instead of sleeps, IdlingResource…
от testland★ 18 звёзд на GitHubОб этом скилле
espresso-suite
Overview
Per espresso-doc:
"Espresso is a framework for writing concise, beautiful, and reliable Android UI tests."
The canonical example:
@Test
fun greeterSaysHello() {
onView(withId(R.id.name_field)).perform(typeText("Steve"))
onView(withId(R.id.greet_button)).perform(click())
onView(withText("Hello Steve!")).check(matches(isDisplayed()))
}
The shape: onView(<matcher>).perform(<action>).check(<matches>).
The framework auto-waits via "synchronization conditions" per espresso-doc:
"Each time a test invokes onView(), Espresso waits to perform the corresponding UI action or assertion until these synchronization conditions are met:
- The message queue doesn't have any messages that Espresso needs to immediately process
- There are no instances of AsyncTask currently executing a task
- All developer-defined idling resources are idle"
This eliminates the need for Thread.sleep for stock Android
async work.
When to use
- An Android app needs UI tests in Google's first-party framework.
- The team is not on cross-platform (Detox / Appium); pure Android stack.
- A flake-prone Espresso suite needs the IdlingResource pattern to stabilize.
Step 1 - Add dependencies
// app/build.gradle
android {
defaultConfig {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}
dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.6.1'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.6.1'
androidTestImplementation 'androidx.test:rules:1.6.1'
}
Per espresso-doc, Espresso ships as multiple packages:
| Package | Purpose |
|---|---|
espresso-core |
Core View matchers, actions, assertions. |
espresso-web |
WebView support. |
espresso-idling-resource |
Synchronization for background jobs. |
espresso-contrib |
DatePicker, RecyclerView, Drawer actions, accessibility checks. |
espresso-intents |
Intent validation + stubbing. |
espresso-remote |
Multi-process functionality. |
Step 2 - Author tests
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.*
import androidx.test.espresso.assertion.ViewAssertions.*
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.ext.junit.rules.ActivityScenarioRule
@RunWith(AndroidJUnit4::class)
class CheckoutTest {
@get:Rule
val activityRule = ActivityScenarioRule(MainActivity::class.java)
@Test
fun applyPromoCode() {
onView(withId(R.id.promo_field)).perform(typeText("WELCOME10"), closeSoftKeyboard())
onView(withId(R.id.apply_button)).perform(click())
onView(withId(R.id.subtotal)).check(matches(withText("$22.49")))
}
}
Step 3 - IdlingResource for app-specific async
When the app uses something Espresso doesn't auto-track (e.g. custom thread pool, RxJava chains), wire an IdlingResource:
class NetworkIdlingResource : IdlingResource {
@Volatile private var callback: IdlingResource.ResourceCallback? = null
@Volatile private var pendingRequests = 0
override fun getName() = "NetworkIdlingResource"
override fun isIdleNow() = pendingRequests == 0
override fun registerIdleTransitionCallback(cb: IdlingResource.ResourceCallback) {
callback = cb
}
fun increment() = synchronized(this) { pendingRequests++ }
fun decrement() = synchronized(this) {
pendingRequests--
if (pendingRequests == 0) callback?.onTransitionToIdle()
}
}
// Wire from production code at network call sites:
networkIdlingResource.increment()
api.fetchOrders().enqueue { _, _ -> networkIdlingResource.decrement() }
// Register in test setup:
@Before fun setup() { IdlingRegistry.getInstance().register(networkIdlingResource) }
@After fun teardown() { IdlingRegistry.getInstance().unregister(networkIdlingResource) }
Without IdlingResource, Espresso assumes idle when its built-in trackers report idle - async work the framework can't see triggers flake.
Step 4 - Common matchers and actions
// Matchers
withId(R.id.button) // by ID
withText("Submit") // by displayed text
withContentDescription("Login") // by content description
hasSibling(withText("Email")) // structural relationshi
Установить espresso-suite в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл espresso-suite?
Use whenever an Android app needs UI tests in Google's Espresso: onView with perform and check, automatic synchronization instead of sleeps, IdlingResource for app async work, ./gradlew connectedAndroidTest and JUnit XML results.
Как установить скилл espresso-suite?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл espresso-suite запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic