How to use monkey and monkey tools to test Android?

How do you use monkey and monkeyrunner to test Android?

What are the basic necessary commands?

+6
source share
4 answers
 adb shell monkey -p com.bla.yourpackage -v 1000 

First, this is your package, in which you want the monkey to work and be limited. The second is a verbose mode, the third is the number of triggered events.

You can find out more by running adb shell monkey -help

+20
source

Here are some helpful tips when using the monkey test.

Specify one action

Add category to manifest:

 <activity android:name="MonkeyActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.MONKEY" /> </intent-filter> </activity> 

and use the command as follows:

 adb shell monkey -p my.package -c android.intent.category.MONKEY -v 500 

Error Notification Prevention

In Android 5.0+, you can use the Screen Pinning feature.

  • open this function in "settings"> "security"> "screen binding"
  • click the recent / multitasking button next to the home button
  • Click the green icon to connect the application you want to test.

then run the monkey test.

stop monkeyTest

Use the following command to stop the monkey test:

 adb shell ps | awk '/com\.android\.commands\.monkey/ { system("adb shell kill " $2) }' 

Link

+4
source

monkey and monkeyrunner are different tools.

A monkey

You can run monkey from adb shell , then it will generate pseudo-random streams of user events. You can specify some conditions and restrictions for the implementation of these events (see documentation )

The basic syntax is:

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

Monkeyrunner

monkeyrunner is an API for controlling an Android device or emulator from outside Android code, as indicated in the documentation. You can write Python scripts that describe some of the actions that must be performed on the target device.

Program example

Quote from Android developers documentation :

The monkey tool is not associated with the Monkey user interface, also known as the monkey tool. The monkey tool runs in the adb shell directly on the device or emulator and generates pseudo-random streams of user and system events. In comparison, Monkey is a tool for managing devices and emulators from a workstation by sending specific commands and events from the API.

+2
source

These three steps will help you configure:

1) Enter this directory - ~/Android/Sdk/platform-tools

2) Start the server - ./adb start-server

3) The command to check 5000 random keystrokes in your application is ./adb shell monkey -p your.package.name -v 500

Check this out for more information. https://developer.android.com/studio/test/monkey.html

0
source

Source: https://habr.com/ru/post/924705/


All Articles