Advanced & Automation
Android 1.0+
Risk: POTENTIALLY_DISRUPTIVE
UI Stress & Monkey Testing
Generates pseudo-random streams of user events (clicks, touches, gestures, system events) to stress test app stability.
Command Syntax
adb shell monkey
Generic Syntax:
monkey [-p <PACKAGE_NAME>] [-v] [--throttle <MS>] [--pct-touch <PCT>] [--pct-motion <PCT>] [--ignore-crashes] [--ignore-timeouts] <EVENT_COUNT>
Options & Parameters
| Flag | Description |
|---|---|
| -p <PACKAGE> | Constrain testing to specified package. |
| -v | Verbose mode: print detailed event stream. |
| --throttle <MS> | Delay in milliseconds between injected events. |
| --ignore-crashes | Continue injecting events even if application crashes. |
| --ignore-timeouts | Continue even if ANR (Application Not Responding) happens. |
| -s <SEED> | Reproduce identical event sequence using a fixed seed number. |
Real-World Usage Examples
Send 5000 random user events to an app
Runs stress test on target app with 5,000 random events.
adb shell monkey -p com.example.app -v 5000
Output:
:Monkey: seed=1724589214 count=5000
:AllowPackage: com.example.app
:IncludeCategory: android.intent.category.LAUNCHER
// Event percentages:
// 0: 15.0%
// 1: 10.0%
Events injected: 5000
## Network stats: elapsed time=12400ms (0ms mobile, 0ms wifi, 12400ms not connected)
// Monkey finished
Run with 100ms throttle between events and ignore crashes
Runs human-speed stress test.
adb shell monkey -p com.example.app --throttle 100 --ignore-crashes --ignore-timeouts 1000
Output:
Events injected: 1000
// Monkey finished