/android-kotlin:testing-setupfrom android-kotlin
Analyze and create a testing strategy for Android apps - install testing
Ships in android-kotlin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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:
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:
testOptions { screenshotTests.create(...) }, as described in Screenshot testing with test suites.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.
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 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, and database-related classes such as DAOs). 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 (through a library such as Room or SQLDelight), create instrumented tests using an in-memory database to make sure that they work with the SQLite engine on device.
Regardless of the framework used, screenshot tests focus on two 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 such as notifications or 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 and where the screenshot reference files live. Also create a new AGENTS.md file in the root and create a link to docs/testing.md.
LICENSE (opens in a new tab)SOURCE.md (opens in a new tab)references/android/develop/ui/compose/testing/common-patterns.md (opens in a new tab)references/android/studio/preview/compose-screenshot-testing-with-testsuites.md (opens in a new tab)references/android/studio/preview/compose-screenshot-testing.md (opens in a new tab)references/android/training/dependency-injection/hilt-testing.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
12 skills in this plugin
Other plugins' skills for the same job
/anr-audit-and-fixAudits Android codebases for ANR risks and diagnoses ANR stack dumps.npx claudepluginhub fcakiroglu16/marketplace --plugin android-kotlin