Monkey testing

Monkey testing is a technique in which random, unplanned input is fed to an application, usually by a tool, with no knowledge of what the application is meant to do, to see whether it crashes, hangs or corrupts data. The name describes the tester: something that presses keys and taps the screen at random. It finds robustness failures, not functional ones.

The longer version

A monkey test is a loop: pick a random point on the screen or a random key, send the event, check that the application is still alive, repeat for thousands of events or a fixed duration. A dumb monkey knows nothing about the interface and sends events anywhere. A smart monkey knows the structure of the interface, which controls exist and what states are valid, and sends random but legal sequences, which reaches deeper. Android ships a tool named for it, and the pass condition is plain: no crash, no hang, no unrecoverable state.

Monkey testing is confused with ad hoc testing because both are unplanned. The difference is that an ad hoc tester has intent, choosing the next action because experience says it might fail, while the monkey has none. It is also confused with fuzz testing, which is its close relative at the data level: fuzzing feeds malformed, unexpected or random data to a parser, a file format or an API, often steered by which code paths earlier inputs reached, while monkey testing feeds random events to a user interface. Neither can tell whether a result is correct, only whether the program survived.

Monkey testing produces crashes nobody can reproduce. The monkey finds a hang after four thousand events and nobody can say which sequence caused it, because the log records events but not the state the application was in when each arrived. A run that did not record the seed of its random generator cannot be replayed at all. The other misuse is reporting a clean monkey run as evidence of quality: it proves the application does not crash under noise, and nothing about whether any feature does what the specification says.

Common questions

What is the difference between monkey testing and ad hoc testing?

Ad hoc testing is unplanned but intentional: a person chooses each action because experience suggests it might break something. Monkey testing is unplanned and unintentional: random events with no model of the application, usually generated by a tool. Ad hoc testing finds functional defects; monkey testing finds crashes and hangs.

What is the difference between a dumb monkey and a smart monkey?

A dumb monkey sends random events anywhere on the screen with no knowledge of the interface, so most events land on nothing. A smart monkey knows which controls exist and which states are legal, and generates random but valid sequences, which reaches states a dumb monkey never would. Smart monkeys cost more to build and find more.

Can monkey testing replace other testing?

Monkey testing cannot replace functional testing, because it has no idea what a correct result looks like and only reports whether the application survived. It belongs alongside scripted and exploratory testing as a robustness check, useful on interfaces that must not crash under arbitrary input, such as mobile apps and kiosks.

What is the difference between monkey testing and fuzz testing?

Monkey testing sends random events, such as taps, keystrokes and gestures, to a user interface and watches for crashes and hangs. Fuzz testing sends malformed or random data to an input that parses it, such as a file format, a network protocol or an API, and is often steered by which code paths earlier inputs reached. Both check survival rather than correctness; they differ in the layer they attack.

How do you reproduce a crash found by monkey testing?

By replaying the same event sequence, which is only possible if the run recorded the seed of its random generator and the tool can regenerate the sequence from it. Without the seed the crash is a one-off. With it, the tester replays the run, trims the sequence to the shortest prefix that still crashes, and writes that up as steps to reproduce, with the application state at each step if the tool can capture it.

Bug reports that arrive ready to triage.

Collect replay, console, network and browser context with the Free plan.

<script src="…/widget.js" data-key="pb_pub_…">