Questions tagged [monkey]

The Monkey is a program that runs on an Android emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. Monkey can be used to stress-test applications, in a random yet repeatable manner.

Overview

The Monkey is a command-line tool that that runs on any Android emulator instance or device. It sends a pseudo-random stream of user events into the system, which acts as a stress test on the application software you are developing.

The Monkey includes a number of options, but they break down into four primary categories:

Basic configuration options, such as setting the number of events to attempt. Operational constraints, such as restricting the test to a single package. Event types and frequencies. Debugging options. When the Monkey runs, it generates events and sends them to the system. It also watches the system under test and looks for three conditions, which it treats specially:

If you have constrained the Monkey to run in one or more specific packages, it watches for attempts to navigate to any other packages, and blocks them. If your application crashes or receives any sort of unhandled exception, the Monkey will stop and report the error. If your application generates an application not responding error, the Monkey will stop and report the error. Depending on the verbosity level you have selected, you will also see reports on the progress of the Monkey and the events being generated.

Basic Use of the Monkey

You can launch the Monkey using a command line on your development machine or from a script. Because the Monkey runs in the emulator/device environment, you must launch it from a shell in that environment. You can do this by prefacing adb shell to each command, or by entering the shell and entering Monkey commands directly.

The basic syntax is:

$ adb shell monkey [options] <event-count>

With no options specified, the Monkey will launch in a quiet (non-verbose) mode, and will send events to any (and all) packages installed on your target. Here is a more typical command line, which will launch your application and send 500 pseudo-random events to it:

$ adb shell monkey -p your.package.name -v 500
145 questions
37
votes
1 answer

How do I execute an adb command in Android Studio?

For example, I want to execute this command from this tutorial: $ adb shell monkey -p your.package.name -v 500 How do I do it? Where do I enter the command? I've tried entering it into the terminal but it says that '$' is not recognized. I also…
Sid Go
  • 2,041
  • 3
  • 16
  • 29
17
votes
1 answer

Monkey made my app meow

I ran the exerciser monkey on my app, and for some odd reason, my app meowed! I have no sound files in my project at all, so I'm a bit confused why a 'meow' sound played. Any explanations here? There are also no other projects/files that operate…
Mxyk
  • 10,678
  • 16
  • 57
  • 76
17
votes
0 answers

Android MONKEY ANR at android.os.MessageQueue.nativePollOnce

We find a tricky ANR problem when using MONKEY to test our app. CPU and memory using is in the normal level. it seems that the ANR is cause by a Timeout KeyEvent faked by MONKEY sending to our app’s Activity. Below is the part of log: “ ANR: …
YUANSHUO ZHU
  • 281
  • 2
  • 6
15
votes
3 answers

How to prevent monkey to open status bar?

I want to use android's monkey for stress test my app but monkey opens status bar and changes settings on my phone. To start monkey I use: adb -s S5660a19e722f shell monkey -p com.lmmx.app -v -v -v 10000 --throttle 500 I thought that -p…
lordmegamax
  • 2,684
  • 2
  • 26
  • 29
13
votes
4 answers

How to use monkey and monkeyrunner tools for android testing?

How do you use monkey and monkeyrunner tools for android testing? What are the basic commands needed?
Terminator
  • 227
  • 1
  • 2
  • 5
13
votes
1 answer

how to filter specific Activities to be tested by monkey using android.intent.category?

I'm trying to stress test my android application using the monkey exercise tool. By default the tool will exercise activities having category Intent.CATEGORY_LAUNCHER or Intent.CATEGORY_MONKEY according to the doc. package="my.android" …
felipe
  • 1,039
  • 1
  • 13
  • 27
12
votes
2 answers

Android Exerciser Monkey starts playing audio files at random

I'm running exerciser monkey to test my android app. As part of my app I play media files which give the pronunciation of a words. I've put the files in a directory where they aren't readable by the Android's Music player. However, the exerciser…
12
votes
4 answers

writing to /system/framework in emulator

I'm in the process of extending monkey for software testing purposes, so I would like to replace the current monkey.jar which my own compiled monkey.jar in the emulator. The current monkey.jar is located at /system/framework/monkey.jar. When I try…
CodingWithoutComments
  • 35,598
  • 21
  • 73
  • 86
11
votes
2 answers

Disable system-level events on Android monkey

While monkey testing my app % adb shell monkey -p com.foo.bar --throttle 1000 -v 14400 I notice that it accesses various system settings on my device like audio control and taking screen shots. According to…
Edmund
  • 111
  • 1
  • 4
10
votes
6 answers

android monkey runner scripts

i am tryig to execute a sample python program through monkey runner command prompt and it is throwing an error Can't open specified script file Usage: monkeyrunner [options] SCRIPT_FILE -s MonkeyServer IP Address. -p MonkeyServer…
saibabu
  • 131
  • 1
  • 1
  • 4
7
votes
2 answers

How to use android monkey

I am a little confused on how to actually use monkey, i thought you were supposed to power on your emulator and go into terminal editor and type: $ adb shell monkey -p insert.my.package.name.here -v 500 since that did not work (error, adb:…
Demonicpenguin
  • 113
  • 1
  • 3
  • 13
7
votes
1 answer

How to prevent Monkey test from opening notification panel and turning OFF wifi?

I am performing Monkey testing on my Android app. While performing events, Monkey pulls down the notification panel and clicks on wifi/mobile data icons, hence turning them OFF. I am using this command: adb shell monkey -p package_name --throttle…
Harminder Singh
  • 1,577
  • 1
  • 11
  • 19
6
votes
1 answer

Monkey giving an odd error on android emulator

I'm letting monkey run on my app (via android emulator) using the following instruction: Monkey -p -v 5000 I am getting the following errors: 01-28 11:45:55.392: ERROR/MediaPlayerService(34): error: -2 01-28 11:45:55.392:…
Will Tate
  • 33,439
  • 9
  • 77
  • 71
5
votes
1 answer

Android: How do you emulate a keyboard flip?

While debugging my app using Monkey (which is almost as fun as the real thing), I managed to crash! Yay, that's what it's for, right? Looking at the log (and while watching) I noticed that Monkey is occasionally doing: :Sending Flip…
SMBiggs
  • 11,034
  • 6
  • 68
  • 83
5
votes
1 answer

Reproduce Android Monkey Script

I ran the Monkey tool (the tool to perform stress testing on Android application) and I got some script file that have this form: type= raw events count= -1 speed= 1.0 start data…
giograno
  • 1,749
  • 3
  • 18
  • 30
1
2 3
9 10