running-instrumented-tests-with-androidjunit4

Community

Fix the runner stack for AndroidJUnit4 tests

Authorskydoves
Version1.0.0
Installs0

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, 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.

Dependency Matrix

Required Modules

None required

Components

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.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.