organizing-test-source-sets

Organize Android test files into correct source sets and Gradle dependency configurations.

303|10|Updated May 15, 2026
One-click install
npx skills add https://github.com/skydoves/android-testing-skills --skill organizing-test-source-sets
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: organizing-test-source-sets
Source: https://github.com/skydoves/android-testing-skills/tree/main/fundamentals/strategies/organizing-test-source-sets
Command: npx skills add https://github.com/skydoves/android-testing-skills --skill organizing-test-source-sets

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It resolves the confusion and build/run failures caused by misplacing Android tests into the wrong source sets or Gradle configurations, especially around src/test/ vs src/androidTest/, src/sharedTest/, and the AGP 7.2+ Compose-style androidHostTest / androidDeviceTest split.

Core Features & Use Cases

  • Source set decisioning: Chooses the correct location for JVM host tests (src/test/) vs instrumented device tests (src/androidTest/) based on the user’s test type.
  • Gradle configuration mapping: Ensures the right dependency scope is used for each source set, including testImplementation, androidTestImplementation, and when debugImplementation is required for test manifests.
  • AGP 7.2+ migration guidance: Explains why src/sharedTest/ source-set sharing breaks and outlines safer alternatives such as splitting into sub-modules or using KMP-style androidHostTest / androidDeviceTest layouts.

Quick Start

Use the organizing-test-source-sets skill to tell me where my test should live and which Gradle dependencies it should use when I’m moving from src/sharedTest to androidHostTest/androidDeviceTest after AGP 7.2.

Frequently Asked Questions about organizing-test-source-sets

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I decide whether an Android test belongs in src/test or src/androidTest?▼

Android test source set selection depends on the runner: src/test hosts JVM unit tests using testImplementation, while src/androidTest runs instrumented device tests using androidTestImplementation to prevent missing framework errors.

What Gradle configuration do I use for Espresso and Robolectric test dependencies?▼

Map testImplementation to src/test for JVM host tests and androidTestImplementation to src/androidTest for instrumented tests to prevent misrouted runners and missing framework errors.

Why does src/sharedTest break after updating to AGP 7.2 and how do I migrate?▼

Migrating away from src/sharedTest after AGP 7.2 involves splitting tests into androidHostTest for JVM tests and androidDeviceTest for instrumented tests, or extracting shared tests into separate sub-modules.

When do I need debugImplementation for Android testing dependencies?▼

debugImplementation is required for ui-test-manifest and fragment-testing-manifest dependencies to ensure test manifests are correctly scoped to the debug build variant without polluting release configurations.

What causes missing framework errors when running Android instrumented tests?▼

Missing framework errors during Android instrumented tests are caused by misrouting JVM host test runners to src/androidTest or placing Espresso artifacts in src/test instead of using androidTestImplementation.

Can I use androidHostTest and androidDeviceTest source sets for shared Android tests?▼

androidHostTest and androidDeviceTest offer a KMP-style source-set layout for shared tests, replacing the broken src/sharedTest approach after AGP 7.2 by cleanly separating JVM host and device instrumented test scopes.