1 -- monkey-based stress testing for Android

Source: Internet
Author: User

Monkey is a self-designed stress testing tool for Android.

It can run in a simulator or on a real device. It sends a pseudo-random user event stream to the system to test the stress of developing applications.

The basic syntax is as follows:
Monkey [Options]

Our general usage:

Monkey-P com. CX. AD (Package)-V 500, type this command to see that the stress test is ongoing on the phone simulator.

The following is an online example (verified );

1. Run cmd To Go To The Android-SDK-Windows \ platform-tools directory of the disk.

2. Enter ADB shell in the command line

3. Enter ls to view the directory in the current folder. The execution result is as follows:

ADB Shell
# Ls
Ls
Sqlite_stmt_journals
Config
Cache
Sdcard
D
Etc
System
Sys
Sbin
Proc
Init. RC
Init. Goldfish. RC
Init
Default. Prop
Data
Root
Dev

4. The application packages are all under data. Enter CD data to enter the data folder, as shown below:

# CD Data
CD Data

5. Enter ls to view the content in the folder, as shown below:

# Ls
Ls
Misc
Local
Data
App-Private
App
Property
ANR
Backup
Dontpanic
Dalvik-Cache
System
Lost + found

6. There is another data. All the applications are under this data. Enter this data and enter the LS as follows:

# CD Data
CD Data
# Ls
Ls
Com. Android. MMS
Com. Android. providers. Applications
Com. Android. globalsearch
Com. Android. calculator2
Com. Android. spare_parts
Com. Android. gesture. Builder
Com. Android. Music
Com. Android. sdksetup
Com. Android. packageinstaller
Com. Android. Fallback
Com. Android. providers. Settings
Com. Android. providers. DRM
Com. Android. Development
Com. Android. providers. Telephony
Com. Android. inputmethod. Pinyin
Com.android.html Viewer
Com. Android. Settings
Com. Android. netspeed
Com. Android. providers. userdictionary
Com. Android. Browser
Com. Android. Contacts
Com. Android. alarmclock
Com. Android. Camera
Com. Android. providers. Contacts
JP. co. omronsoft. openwnn
Com. Android. Launcher
Com. Android. Phone
Com. Android. soundrecorder
Com. Google. Android. providers. enhancedgooglesearch
Com. svox. Pico
Com. Android. customlocale
Com. Android. Term
Com. Android. providers. downloads
Com. Android. providers. Media
Com. Android. Email
Android. TTS
Com. Android. inputmethod. Latin
Com. Android. server. VPN
Com. example. Android. APIs

7. The last one is the application package of apidemo we just loaded.

8. you can directly enter monkey-p com. example. android. APIS-V 50. The result is as follows. You can also exit the shell and enter ADB shell monkey-p com. example. android. APIS-V 500. During the running process, the applications in the emulator are constantly switching the screen. You can take a look, haha :)

# Monkey-P com. example. Android. APIs-V 50
Monkey-P com. example. Android. APIs-V 50
: Monkey: seed = 0 count = 50
: Allowpackage: COM. example. Android. APIs
: Includecategory: Android. Intent. Category. Launcher
: Includecategory: Android. Intent. Category. Monkey
// 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%
: Switch: # intent; Action = Android. Intent. Action. Main; Category = Android. Intent. Categ
Ory. launcher; launchflags = 0x10000000; Component = com. example. Android. APIs/. apidemos
; End
// Allowing start of intent {act = Android. Intent. Action. Main cat = [Android. In
Tent. Category. Launcher] CMP = com. example. Android. APIs/. apidemos} in package COM.
Example. Android. APIs
: Sending pointer action_move x =-4.0 y = 2.0
: Sending pointer action_up x = 0.0 y = 0.0
// Allowing start of intent {CMP = com. example. Android. APIs/. apidemos} in PA
Ckage com. example. Android. APIs
: Sending pointer action_down x = 207.0 y = 282.0
: Sending pointer action_up x = 189.0 y = 289.0
// Allowing start of intent {CMP = com. example. Android. APIs/. App. intents} in
Package com. example. Android. APIs
: Sending pointer action_down x = 95.0 y = 259.0
: Sending pointer action_up x = 95.0 y = 259.0
: Sending pointer action_down x = 295.0 y = 223.0
: Sending pointer action_up x = 290.0 y = 213.0
: Sending pointer action_move x =-5.0 y = 3.0
: Dropped: Keys = 0 pointers = 0 trackbils = 0 flips = 0
# Network stats: elapsed time = 3799 ms (3799 Ms mobile, 0 Ms WiFi, 0 Ms not connecte
D)
// Monkey finished

Now that the test is complete, anrs ("application not responding") may appear during the test, indicating that there is a bug,

ANR occurs. Generally, the response of the main thread exceeds 5 seconds, or broadcastreceiver does not respond within 10 seconds. This is a serious defect.

You can process the time-consuming operations in another thread.

 

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.