running-instrumented-tests-with-androidjunit4
CommunityFix the runner stack for AndroidJUnit4 tests
System Documentation
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, andSmall/Medium/Largefilters while avoiding deprecated or legacy imports. - Proper Gradle runner configuration: Ensures
testInstrumentationRunneris set to theandroidx.test.runner.AndroidJUnitRunnerclass and that runner arguments can be read via the canonical registry API. - Test Orchestrator and runtime permission correctness: Installs Orchestrator via
androidTestUtil(notandroidTestImplementation) and grants permissions usingGrantPermissionRulefor scoped, revertable permission handling. - Flake-reduction defaults: Disables animations via
testOptions.animationsDisabled = trueand applies the proper@SmallTest/@MediumTest/@LargeTestguidance for size-based filtering. - Common failure troubleshooting: Targets issues like “Test runner not found”, “InstrumentationRegistry deprecated”, orchestrator not running, ignored
-eargs, 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.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: running-instrumented-tests-with-androidjunit4 Download link: https://github.com/skydoves/android-testing-skills/archive/main.zip#running-instrumented-tests-with-androidjunit4 Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.