Using Monkey to test Android, entry-level users may encounter errors and solutions

Source: Internet
Author: User

One, the D:\android\android-sdk-windows\tools directory does not have Adb.exe

Check your android-sdk-windows directory for any platform-tools directories. and check to see if there are any adb.exe in the interview directory

Second, execute "adb shell" in cmd, then prompt "Error:device not found"

No devices found. If you are testing with a mobile device, connect it to your computer with a USB cable, and install a mobile phone driver; If you are using simulator testing, you should start Eclipse, set up the simulator, and enter the simulator test status as shown in

Third, execute "adb shell", prompt "Error:more than one device and emulator"

The first scenario: do use multiple devices or simulators

The error description is that there is more than one device and emulator. This is because I enabled the emulator and I also connected my phone to the computer via a USB cable. So there are two of devices here. In this case, you need to specify a device or emulator to connect to.

1. Get a list of emulators or devices

Command: ADB devices
The effect is as follows:

2. Specify device to execute ADB shell

Command: adb-s devicename Shell

In multiple device cases, executing the ADB command typically requires the device to be specified with the parameter-S.

For example, uninstalling the package Com.soft.camera on emulator-5554, the command is as follows
Adb-s emulator-5554 Uninstall Com.soft.camera

For example, by monkey testing
Adb-s emulator-5554 Shell Monkey-v-P your.www.com 500

Second case: There is a device or simulator

There are multiple displays because this device was used two times. Using the command ADB devices will see this device in two different ways: offline and device, with the following two solutions:

1. Restart Adb.exe Service

General approach: Enter ADB start-server in the command window to restart the Adb.exe service

2. The ultimate method to end the ADB process

If the above method is not possible, the ultimate method: Open the taskbar, select the "Process" tab, find the Adb.exe process, end it, restart the finished ok (or in the Command Window Input command adb kill-server)

Four, on the mobile phone through the monkey test

Input in cmd: adb-s ht21jv204550 Shell Monkey-v-P your.www.com 500

Appears: No activities found to run, monkey aborted.

Cause: At first I was through a simulated environment test, the Eclipse settings are as follows:

With mobile testing, the "Target" tab should be changed from "Automatic" to "Manual" as shown in:

Then select "Android" On the previous tab of the "Target" tab and click "Run" below. After run, the results are as follows:

Click OK, the program will write the APK to the phone, you can enter the command in cmd: adb-s ht21jv204550 Shell Monkey-v-P your.www.com 500, by the real-time mobile phone environment to test.

V. Brief overview of the monkey command

一、九个 events and Percent control

1, nine events

--pct-touch <percent> 0
Adjust the percentage of touch events (Touch event is a down-up event that occurs in a single location on the screen) (--click event, involving down, up)

--pct-motion <percent> 1
Adjust the percentage of action events (an action event consists of a down event, a series of pseudo-random events, and an up event on the screen) (--Note: Move event involving down, up, move three events)

--pct-trackball <percent> 2
Adjust the percentage of track events (track events consist of one or several random movements, sometimes accompanied by clicks)--(Trackball)

--pct-nav <percent> 3
Adjust the percentage of basic navigation events (navigation events consist of up/down/left/right from the direction input device)

--pct-majornav <percent> 4
Adjust the percentage of primary navigation events (these navigation events usually trigger actions in the graphical interface, such as: 5-way keyboard, Fallback button, menu button)

--pct-syskeys <percent> 5
Adjust the percentage of the System key event (these keys are usually reserved for use by the system, such as home, back, Start call, End call, and volume control keys)

--pct-appswitch <percent> 6
Adjusts the percentage of startup activity. In a random interval, monkey executes a startactivity () call as a way to maximally cover all activity in the package. (Jump from one activity to another activity)

--pct-flip <percent> 7
Adjusts the percentage of the keyboard rollover event.

--pct-anyevent <percent> 8
Adjusts the percentage of other types of events. It includes all other types of events, such as keystrokes, other infrequently used device buttons, and so on.

The red numbers correspond to the percentages below. For example, 0:15.0%, which represents the allocation of--pct-touch event 15%. Test 100 Allocations 15 times test down-up.

2. Percent control

If the above parameters are not specified in the monkey parameter, these actions are randomly assigned, and the sum of each of the 9 actions is assigned as a percentage of 100%, we can control the percentage of each event by adding a command option, which allows the operation to be limited to a certain extent.

Let's take a look at the non-action percent control, the system default allocation event percentage

Command: adb shell monkey-v-P your.www.com 500

Results:

Take a look at the specified event, after controlling the percentage of events

Command: adb shell monkey-v-P your.www.com--pct-anyevent 100 500

Results:

Description:--pct-anyevent 100 indicates that the percentage of events represented by Pct-anyevent is 100%.

Ii. restriction and determination of the corresponding package name

1. Restriction

-P <allowed-package-name>

The 1-P option can only be used for one package. Specifying multiple packages requires multiple-p options

2. Determine the test package name

Use the monkey test to determine the package name that the application corresponds to in emulator with the-p parameter. The steps are as follows:

A. Open the project you want to test in Eclipse and execute it in the emulator. At this point, his apk should be loaded into the emulator (translator, emulator) (

You can also open the emulator, install and delete the APK from the command mode.

Boot emulator: EMULATOR-AVD test test for Emulator name

Installation: adb install c:/xxx.apk

Delete: adb uninstall APK package name

B. Enter command at command line: adb shell

C, the application package is in the data directory in the data directory, we enter the command: CD Data/data into the target data folder, execute command: LS, you can find the application package just loaded project. As shown in the following:

Once the corresponding package name is found, it can be tested by the Monkey command. Example: adb shell monkey-v-P your.www.com 500

In a word, the last 500 indicates that the test triggered 500 events (500 events to be prorated into 9 events, and how to specify different proportions of the events already mentioned).

If you insert a delay between events, use the parameter:--throttle 5000 Here The 5000 is the millisecond unit. With this option, you can reduce the execution speed of the monkey, and if you do not specify this option, monkey will not be delayed and events will be generated as soon as possible.

-S <seed> pseudo-random number generator's seed value. If you run monkey again with the same seed value, it will generate the same sequence of events, assigning the same percentage to 9 events.

Each-V of the-V command line increases the level of feedback information.

As for the other parameters, Baidu a bit, for the time being first written here.

Six, in the Monkey Test Common command combination has

1, monkey-p com.yourpackage-v 500 simple output test information.
2, monkey-p com.yourpackage-v-v-v 500 output test information in depth of three levels.
3, monkey-p com.yourpackage--port Port number-V for the test to assign a dedicated port number, but this command can only output the information of the jump and error when the output information.
4, monkey-p com.yourpackage-s Digit-V 500 is a random number of event sequence to set a value, if there is a problem next can repeat the same series to debug.
5, Monkey-p com.yourpackage-v--throttle 3000 500 sleeps 3000 milliseconds after performing a valid event for each time.

Using Monkey to test Android, entry-level users may encounter errors and solutions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.