testing-setup
できること
このスキルは、Androidプロジェクトが今どのようにコードをテストしているかを確認し、テストの設定を計画します。ユニット、UI、スクリーンショット、エンドツーエンドのテストのライブラリとハーネスを追加できます。動くテスト戦略がほしいAndroid開発者向けです。
使う場面
- ✓Androidプロジェクトのテストがほとんどない、または全くないとき。
- ✓ComposeやViewの画面のために、スクリーンショットテストを追加したいとき。
- ✓プロジェクトがすでに使っているテストのライブラリとモッキングのツールを知りたいとき。
スキルのリンク
https://github.com/android/skills/blob/main/testing/testing-setup/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のAndroidプロジェクトのテストの設定を確認し、ユニットテストとCompose UIテストのためのライブラリを追加してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルは、バージョンカタログとビルドファイルを読み、依存性の注入のフレームワーク、テストのフレームワーク、モッキングのツール、UIの種類を見つけます。そのうえで、プロジェクトに合う不足しているライブラリとハーネスを追加します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Step 1: Analyze the current testing setup
To understand the testing setup of an existing project, look for these dependencies in the libs.versions.toml file, or build files:
- Dependency Injection framework used. For example, Hilt, Koin, Anvil, or vanilla Dagger.
- Unit (local) testing framework this project uses. For example, JUnit4 or JUnit5.
- Mocking framework (if any) used for unit tests, and for instrumented and UI tests. For example, Mockito or Mockk.
- Robolectric. Identify which of these three uses apply:
- Used in unit tests to have fakes for platform entities
- To run behavior UI tests without a device or emulator. For example, used to run Espresso or Compose tests.
- To do screenshot testing with Roborazzi
- Is the app 100% Compose, Views or hybrid?
- Behavior UI tests:
- Compose Tests (
androidx.compose.ui:ui-test-*) - Espresso Tests for Views. Check for wrappers such as Kaspresso. Dependencies:
androidx.test.espresso:espresso-core,androidx.test:runner,androidx.test:rules.
- Compose Tests (
- Screenshot tests. Identify which of these types the project uses:
- Instrumented (device-based). For example, using Dropshots.
- Based on Robolectric, so they run locally. For example, using Roborazzi.
- Based on LayoutLib, so they run locally. For example, Paparazzi, or the Compose Preview Screenshot Testing tool.
- End to end tests (also known as Release Candidate tests) always run on device and use high-level frameworks such as UIAutomator, Appium, or Robotium.
- Generate a Markdown report with the analysis
Step 2: Set up Dependency Injection frameworks for testing
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.
Step 3: Install frameworks
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:
JUnit4 for local and instrumented tests
JaCoCo for test coverage
For UI tests: if the project has views, Espresso. If it's fully Compose, use the Compose Testing APIs.
Robolectric to run UI Tests
Compose Preview Screenshot Testing tool for screenshot tests. Check the project's AGP version first, then pick the matching setup and follow it strictly:
- AGP 9.5.0-alpha03 or higher (recommended): configure an AGP test suite using
testOptions { screenshotTests.create(...) }, as described in Screenshot testing with test suites. - Lower AGP versions: use the legacy standalone plugin setup with
com.android.compose.screenshot, and tell the user it's deprecated. Don't upgrade AGP as part of setting up screenshot tests. Mention that test suites are available on 9.5.0-alpha03 or higher, and leave the upgrade as a separate decision.
Don't combine both setups in the same module. If the project already uses the standalone plugin and its AGP version supports test suites, offer to migrate it using the tasks and paths mapping table in Screenshot testing with test suites.
- AGP 9.5.0-alpha03 or higher (recommended): configure an AGP test suite using
Dropshots for device screenshot tests
If a mocking framework is necessary, install Mockk (
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
よくある質問
実際のテストケースも書きますか?
このスキルはテストの設定とハーネスに焦点を当てるため、どの振る舞いをテストするかはあなたが決めます。
どの種類のスクリーンショットテストを知っていますか?
デバイスを使うスクリーンショットテストと、Robolectricまたは LayoutLibに基づくローカルのものを認識します。
どの依存性の注入のツールを認識しますか?
Hilt、Koin、Anvil、素のDaggerなどのフレームワークを認識します。
詳細
作者による元の説明
Analyze and create a testing strategy for Android apps - install testing libraries, set up test infrastructure, create harnesses for unit tests, UI tests, screenshot tests, and end-to-end tests.
repo: android/skills
人気
- GitHubのスター
- 10k
- ランキング
- #11937
- ライセンス
- Apache-2.0
- 更新日
- 2026/10/29
コメント
- …
このリポジトリの他のスキル
agp-9-upgrade
10kエージェントが、AndroidアプリをAndroid Gradle Plugin 9にアップグレードし、その破壊的変更に対応できるよう支援します。マルチプラットフォームのプロジェクトは対象外です。
camerax
10kエージェントが、CameraXを使ってAndroidのカメラ機能を作れるよう支援します。動画の録画、ハードウェアの制御、ML Kit、Media3のエフェクトを含みます。
android-for-cars-parked-apps
10kエージェントが、Androidの動画、ゲーム、ブラウザのアプリを、Android AutoとAndroid Automotiveで駐車中のアプリとして動かせるように適合させるよう支援します。
appfunctions
10kエージェントが、Androidアプリの主要な作業の流れを見つけ、AIエージェントや音声コマンドが実行できるAppFunctionsとして公開できるよう支援します。
似ているスキル
test-driven-development
311k機能や修正を作る前に、まず失敗するテストを書き、それが失敗するのを確認してから、合格させる最小のコードを書くようエージェントに教えます。
verification-before-completion
311kタスク、修正、ビルドが完了した、または合格したと主張する前に、実際のチェックを実行し、その出力を読むようエージェントに教えます。
migrate-to-shoehorn
310kテストファイル内の危険な型キャストを、shoehornライブラリに置き換え、テストが部分的なデータを使いつつ型チェックを通るようにします。