con un clic
testing-setup
为原生 Android 应用分析并制定测试策略——安装测试库、搭建测试基础设施、为单元测试、UI 测试、截图测试和端到端测试创建测试桩。
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Menú
为原生 Android 应用分析并制定测试策略——安装测试库、搭建测试基础设施、为单元测试、UI 测试、截图测试和端到端测试创建测试桩。
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Basado en la clasificación ocupacional SOC
提供使用 CameraX 进行 Android 相机开发的技术指导。当实现相机功能、处理异步录制生命周期、使用 CameraX 进行底层硬件互操作,或集成 ML Kit 或 Media3 特效时使用。
提供基于 Android Credential Manager API 实现已验证邮箱获取的完整工作流。使用此 skill 向 Android 应用集成安全、免 OTP 的邮箱验证流程。该 skill 利用来自 Google 等可信提供商的加密验证凭证,解决注册流程摩擦过大的问题。
提供让应用 UI 适配不同 Android 设备(手机、平板、折叠屏、笔记本、桌面、TV、Auto 和 XR)的说明。涵盖使用 Compose MediaQuery API 处理不同窗口尺寸、指针设备(如鼠标)和文本输入设备(如键盘);使用 Navigation3 Scenes 实现多窗格布局;使用 Compose Grid 和 FlexBox API 实现随目标尺寸变化的自适应 UI 组件(如按钮)和自适应布局(含导航区——nav rails 和 nav bars)。
提供将 Android XML View 迁移到 Jetpack Compose 的结构化工作流。该 skill 详述从规划和依赖设置,到主题和布局迁移、验证及 XML 清理的分步流程。当需要在 Android 项目中把 XML View 迁移到 Jetpack Compose 时使用。它解决将旧版 XML View 的 UI 转换为现代声明式 Compose 组件、同时保持互操作性的问题。
使用此 skill 将 Jetpack Compose Styles API 集成到 Android 项目。引导你升级依赖、设置组件主题、让自定义组件可样式化,以及将现有布局属性迁移到统一样式。迁移自定义设计系统组件、用 Style 属性替换硬编码参数、使用 Modifier.styleable 处理交互状态。
学习如何安装并迁移到 Jetpack Navigation 3,以及如何实现 deep links、多个 backstack、scenes(对话框、底部表、list-detail、two-pane、supporting pane)、条件导航(如已登录导航 vs 匿名导航)、从流程返回结果、与 Hilt/ViewModel/Kotlin/View 互操作集成等功能和模式。
| name | testing-setup |
| description | 为原生 Android 应用分析并制定测试策略——安装测试库、搭建测试基础设施、为单元测试、UI 测试、截图测试和端到端测试创建测试桩。 |
| license | Complete terms in LICENSE.txt |
| metadata | {"author":"Google LLC","last-updated":"2026-06-25","keywords":["android","testing","ui tests","screenshot tests","coverage"]} |
To understand the testing setup of an existing project, look for these dependencies in the libs.versions.toml file, or build files:
androidx.compose.ui:ui-test-*)androidx.test.espresso:espresso-core, androidx.test:runner, androidx.test:rules.If there is no Dependency Injection framework, install one: if it's a multiplatform application, ask the user whether they want to install Koin, or kotlin-inject. If it's not multiplatform, install Hilt.
Install the testing dependencies (for example com.google.dagger:hilt-compiler
that should be applied with a kspAndroidTest configuration).
[!IMPORTANT] Important: Always consult the documentation of the applicable framework to learn about testing (for example: Hilt testing guide, Koin Instrumented tests).
For instrumented tests, create and configure (by adding
testInstrumentationRunner to the build gradle files) a new test runner and
apply the testing rules required by the framework (for example in Hilt, annotate
your test classes with @HiltAndroidTest and apply the HiltAndroidRule).
Other frameworks use other mechanisms, consult their documentation.
Unless otherwise specified, respect the current stack of testing frameworks.
If there are no testing frameworks, and the user didn't specify any preference, install the following:
io.mockk:mockk). Do not install it unless it is clearly necessary.If instrumented screenshot tests are requested, install Dropshots.
If end-to-end testing is requested, install UI Automator.
In the next sections you'll be asked to create tests. If you have dependencies on Android framework classes, or entities that are not part of the codebase:
First, use a fake. If it doesn't exist, create an interface for the class and a "Default" implementation with the existing code. Add the Fake version to the test sourceset (test or androidTest).
If not possible to use a fake (example: no access to the class or interface), mock the dependencies.
If you need to fake components to make testing easier and faster and more reliable, replace slow and problematic dependencies with fakes. Use runtime fakes using the Dependency Injection framework installed to:
Create a task to add or review unit tests in every file that contains business logic (ViewModels, Repositories, database-related classes such as DAOs, etc.). Don't create unit tests for Activities, Compose layouts, or dependency injection configuration files.
Espresso or Compose UI tests live in the test sourceset because they will be
run with Robolectric. If instrumented (emulator or device) tests are requested,
put them in the androidTest sourceset.
If the database is using SQLite (using Room, SQLDelight, etc.), create instrumented tests using an in-memory database to make sure that they work with the SQLite engine on device.
Irrespective of the framework used, screenshot tests focus on 2 types of tests:
Behavior isn't tested with screenshots, but do test different common scenarios if their UIs change a lot depending on the state. For example, test loading screens by injecting a loading state to the UI or simulating it with a fake.
Test the UI logic using behavior tests, which ensures that the UIs react as expected when different states are passed, and when user actions are performed.
ComponentActivity to access resources such as strings.testTag.Use Espresso to match views and interact with them.
Create a test suite to verify navigation logic. Include:
For Compose layouts, use DeviceConfigurationOverride described in "UI testing
common patterns" to simulate different window sizes, font scales
Create a low number (about 5% of all tests) of end-to-end tests that cover big user journeys. Use Compose Test APIs or Espresso for that. If you have to access platform features (notifications, system UI...), use UI Automator.
If you need to take screenshots of the app running in a device, use Dropshots. You need a device for screenshot tests when verifying interaction with the system UI (examples: edge-to-edge rendering, notifications, picture-in-picture)
Install the com.dropbox.dropshots plugin in the module and a Dropshots()
JUnit Rule. Create a new instrumented screenshot test for one of the app's
features.
Install jacoco for local testing code coverage.
jacoco plugin to each module that contains tests.Ask whether to document the findings of the analysis and the changes applied to the testing strategy. If the user agrees:
If there is an AGENTS.md file present in the project, update it with any changes you've made to the testing strategy.
If there is no AGENTS.md file, create a new file (docs/testing.md) with a description of the testing strategy, including the commands needed to run every type of test, where the screenshot reference files live, etc. Also create a new AGENTS.md file in the root and create a link to docs/testing.md.