What problem does it solve?
It prevents instrumented tests from failing or misbehaving due to an incorrectly configured AndroidJUnit4 runner stack, including dependency wiring, registry imports, Test Orchestrator setup, and hermetic test defaults.
Core Features & Use Cases
- Correct AndroidX Test dependency matrix: Uses the right artifacts for
AndroidJUnit4, InstrumentationRegistry, rules, and Small/Medium/Large filters while avoiding deprecated or legacy imports.
- Proper Gradle runner configuration: Ensures
testInstrumentationRunner is set to the androidx.test.runner.AndroidJUnitRunner class and that runner arguments can be read via the canonical registry API.
- Test Orchestrator and runtime permission correctness: Installs Orchestrator via
androidTestUtil (not androidTestImplementation) and grants permissions using GrantPermissionRule for scoped, revertable permission handling.
- Flake-reduction defaults: Disables animations via
testOptions.animationsDisabled = true and applies the proper @SmallTest/@MediumTest/@LargeTest guidance for size-based filtering.
- Common failure troubleshooting: Targets issues like “Test runner not found”, “InstrumentationRegistry deprecated”, orchestrator not running, ignored
-e args, and instrumentation tests that won’t compile.
Quick Start
Ask an AI coding agent to configure your module’s androidTestImplementation and androidTestUtil dependencies for AndroidX Test 1.7.0/1.3.0, set testInstrumentationRunner to androidx.test.runner.AndroidJUnitRunner, update imports to androidx.test.ext.junit.runners.AndroidJUnit4 and androidx.test.platform.app.InstrumentationRegistry, enable Test Orchestrator under androidTestUtil, and use GrantPermissionRule for runtime permissions while disabling animations.