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
5
votes
2 answers

Using Monkey in a subactivity only (android debugging)

I'm trying to use Monkey debuggin tool (from adb) to stress test a part of my application. As Monkey acts in a total random way, I'd like it to concentrate on the part of code that might contain an error I'm looking for (very rare bug, and I don't…
kajman
  • 1,066
  • 11
  • 24
5
votes
1 answer

How to avoid lock screen event during monkey test

i am running monkey tests and i am facing issues with lock screen. i have tried running tests with default command as below "monkey -p com.xyz -v 1500000 -s 10000 --throttle 15000" The tests start fine but eventually get to lock screen and thereby…
sandeep
  • 121
  • 10
5
votes
1 answer

Why does gevent.socket break multiprocessing.connection's auth

I have an application that uses both grequests and multiprocessing.managers for a combination of IPC communication and Asynchronous RESTful communications over HTTP. It seems that grequests, in using gevent.monkey's patch_all() method, breaks the…
Nisan.H
  • 6,032
  • 2
  • 26
  • 26
5
votes
1 answer

a ClassCastException about anonymous class (java)

now i get some logs like below (log-1) java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to ClassA$1 at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1010) ... line 1010 final…
android_su
  • 1,637
  • 4
  • 21
  • 30
4
votes
1 answer

Monkey throwing security exception even though they are disabled

He everyone, I am getting this exception java.lang.SecurityException: Permission Denial: android.intent.action.CLOSE_SYSTEM_DIALOGS and Im not sure where its coming from as the app im testing doesnt use…
JRowan
  • 6,824
  • 8
  • 40
  • 59
4
votes
1 answer

How to prevent from Android monkey to turn off WIFI?

Sometimes, WIFI is turned off with following command to run monkey test on Android. Is there any method to prevent the Android monkey to turn off WIFI? adb -s foo shell monkey -p com.foo.bar --throttle 300 --kill-process-after-error --pct-syskeys 0…
4
votes
3 answers

Android Test Monkey - Set Verbosity?

How can I change the verbosity level when running Test Monkey from the command line? These two commands work: adb shell monkey -p com.my.package 5000 adb shell monkey -p com.my.package -v 5000 The Developer docs say, "Each -v on the command line…
user359519
  • 711
  • 2
  • 16
  • 28
4
votes
1 answer

Correct usage of the "--throttle" parameter of monkey?

I could not set the interval between the generated events by monkey. The official documentation defines the usage of --throttle as "Inserts a fixed delay between events. You can use this option to slow down the Monkey. If not specified, there is no…
talha06
  • 6,206
  • 21
  • 92
  • 147
4
votes
1 answer

How to use the monkey command with an Android system that doesn't have physical keys?

If the Android system doesn't have physical keys, what are the parameters need to be included in the command? I get the error: Error : ** SYS_KEYS has no physical keys but with factor 2.0%
user7792128
  • 99
  • 1
  • 6
4
votes
2 answers

Will Monkey test occasionally enter settings and click the restart button to restart device?

When doing a Monkey test on android device, I send adb shell monkey --ignore-security-exceptions --ignore-crashes --ignore-timeouts --ignore-native-crashes --throttle 200 -s 222 -v -v -v 125000 > c:\all_monkey.txt then Monkey will send a lot of…
jiajia guo
  • 332
  • 2
  • 3
  • 16
4
votes
2 answers

Can't see my App package in Android>data folder of my phone

I am working on Android Studio and I cannot see my package inside Android>Data folder of my device when I run apk on it. I am unable to run monkey without it. I have also mentioned installLocation="auto" in manifest and gave WRITE_EXTERNAL_STORAGE…
Ravi Kumar
  • 51
  • 1
  • 4
4
votes
1 answer

Testing Android App - Monkey aborted

I am trying to test some Android App using monkey. But using Monkey to testing has proven to not always be so intuitive, as it doesn't work out of the box as someone could expect. I even read that some others incurred in similar problems, although…
Sophia Taylor
  • 248
  • 2
  • 8
4
votes
1 answer

How to reproduce android monkey crash?

i test the smart phone of android, in command line mode for input : adb shell monkey -v 10000 the result is----------------------------------------------------------------------: procrank: // Exception from procrank: java.io.IOException:…
DanielHsu
  • 115
  • 4
  • 10
4
votes
2 answers

What's the meaning of "Event" from Android Monkey Test report?

from the report of Android Monkey Test. Event percentages: 0: 15.0% 1: 10.0% 2: 15.0% 3: 25.0% 4: 15.0% 5: 2.0% 6: 2.0% 7: 1.0% 8: 15.0% What's the exactly meaning of 0-8 ?
susantjs
  • 939
  • 2
  • 10
  • 19
3
votes
2 answers

what would be the base optimal throttle and seed for an application using monkey test?

I am running monkey test on my application using following command adb shell monkey -p com.droigons.mygps --throttle 1000 -s 1000 -v 500000 > test.txt what would be the base optimal throttle and seed for an application?
droigons
  • 255
  • 4
  • 16
1
2
3
9 10