running-instrumented-tests-via-adb

Run Android instrumented tests via adb and parse status codes for failures.

303|10|Updated May 15, 2026
One-click install
npx skills add https://github.com/skydoves/android-testing-skills --skill running-instrumented-tests-via-adb
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: running-instrumented-tests-via-adb
Source: https://github.com/skydoves/android-testing-skills/tree/main/adb/tests/running-instrumented-tests-via-adb
Command: npx skills add https://github.com/skydoves/android-testing-skills --skill running-instrumented-tests-via-adb

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you run Android instrumented tests from CI or scripts using adb, avoiding Gradle and preventing misleading outcomes when tests fail.

Core Features & Use Cases

  • Run instrumented tests via adb shell am instrument using the required -w (wait) and -r (raw output) flags for reliable CI consumption.
  • Select and slice test runs with -e arguments such as class, class#method, package, and sharding via numShards/shardIndex.
  • Use AndroidX Test Orchestrator correctly with the proper runner/target wiring (-e targetInstrumentation ... plus the orchestrator as the positional last argument), including clearPackageData.
  • Detect real pass/fail by parsing INSTRUMENTATION_STATUS_CODE (e.g., -2 failure, -1 error) instead of trusting the shell exit code.

Quick Start

Run your single test method directly from a script by calling adb shell am instrument -w -r -e class com.example.MyTest#myMethod com.example.app.test/androidx.test.runner.AndroidJUnitRunner.

Frequently Asked Questions about running-instrumented-tests-via-adb

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

FAQPage Schema
How do I run Android instrumented tests via adb without Gradle?▼

Run Android instrumented tests via adb by executing `am instrument` with `-w` and `-r` flags, bypassing Gradle entirely while producing deterministic stdout framing for reliable CI consumption.

Why does my adb instrumented test show passing when tests are actually failing?▼

The adb shell exit code is misleading for instrumented tests. You must parse the `INSTRUMENTATION_STATUS_CODE` values from the raw output, where `-2` indicates failure and `-1` indicates an error, to accurately detect pass/fail outcomes.

How do I run a single test method using am instrument?▼

To run a single test method, use the `-e` argument to specify the target, such as `-e class com.example.MyTest#myMethod`, followed by your test package and runner component name in the `am instrument` command.

Can I use AndroidX Test Orchestrator with adb shell am instrument?▼

Yes, you can use AndroidX Test Orchestrator by passing it as the positional last argument, wiring the runner with `-e targetInstrumentation`, and optionally enabling `clearPackageData` for test isolation.

How do I shard instrumented tests for CI scripting using am instrument?▼

You can shard instrumented test suites by passing `-e` arguments with `numShards` and `shardIndex` to `am instrument`, allowing you to slice and distribute test runs across multiple CI executors.