Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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
Полный SKILL.md на GitHub

Установить espresso-suite в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

.tessl-plugin/plugin.jsonevals/clicks-land-on-the-keyboard-in-checkout/criteria.jsonevals/clicks-land-on-the-keyboard-in-checkout/task.mdevals/espresso-compose-hybrid/criteria.jsonevals/espresso-compose-hybrid/task.mdevals/espresso-intents-camera/criteria.jsonevals/espresso-intents-camera/task.mdevals/espresso-recycler/criteria.jsonevals/espresso-recycler/task.mdevals/german-lane-red-while-the-english-one-is-green/criteria.jsonevals/german-lane-red-while-the-english-one-is-green/task.mdevals/nightly-run-red-but-every-test-passes-alone/criteria.jsonevals/nightly-run-red-but-every-test-passes-alone/task.mdevals/orders-tests-hang-after-the-asynctask-rewrite/criteria.jsonevals/orders-tests-hang-after-the-asynctask-rewrite/task.mdevals/product-wants-coverage-that-follows-the-user-out-of-the-app/criteria.jsonevals/product-wants-coverage-that-follows-the-user-out-of-the-app/task.md

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), без исполняемых скриптов.

Похожие скиллы

Сравнить espresso-suite с