App Stress test Finishing

Source: Internet
Author: User
Tags string format

Stress test Results :
CRASH: Crash, application in use process, non-normal exit
Anr:application Not Responding


Monkeyrunner APIs
Monkeyrunner: Used to connect a device or simulator
monkeydevice: Provides installation, uninstall app, send simulation event
monkeyimage : Complete image preservation, and contrast operation

Monkey: Generate pseudo-random events for users or systems in adb shell
Monkeyrunner: Defining specific commands and event control devices through the API

Monkeyrunner provides a range of APIs
Simulate events and actions can be completed
Monkeyscript
is a set of commands that can be recognized by monkey
Repeatable fixed operations can be done

1. Why stress testing?
App is not stable
Increase the retention rate of products

2. when to conduct stress tests
After the first round of functional test passed
The night after work.

How to implement automated testing:
Simulate various event streams

Adb:android Debug Bridge
ADB communicates with monkey on the phone
Entrance to the ADB debug application

adb Shell Monkey 1000
Activityresuming (Com.android.documentsui)
Indicates that the app is in the background from the front of the console ... The process of recovering from the background to the foreground

Get the App package name
ADB logcat|findstr START (the package name of the app is behind the CMP)

Put pressure on the specified package
ADB Shell MONKEY-P Package 1000

-V
Action: Each-V on the command line will increase the verbosity level of the feedback information
The more commonly used is-v-v-V, which is most detailed and is typically saved to the specified
File for developers to find out why the bug is being used

--throttle parameters
Specify the interval between events
adb shell monkey-p packagename--throttle interval milliseconds execution times

Seed parameter
To specify the seed value of a randomly generated number
If you run monkey again with the same seed value, the same sequence of events will be generated
ADB Shell monkey-s<seed><event-count>
adb shell monkey-p com.bit_health.android-s 7672 1000

Touch events
Set Touch Event Percentage
adb Shell Monkey--pct-touch <percent>
adb shell monkey-v-P com.bit_health.android--pct-touch 100 1000
You can see if it is in the event percentages in the output results
Touch event hundred percent, 0 means touch event

Action Events
Set the percentage of action events
adb Shell Monkey--pct-motion <percent>
The percentage set here is equal to 100 of the percentage of other events.
adb shell monkey-v-P com.bit_health.android--pct-touch--pct-motion 30 500

Trackball Events
Set Trackball Event Percentage
adb Shell Monkey--pct-trackball <percent>

Basic Navigation Events
Set basic event percentage, enter the device's top, bottom, left, and right
adb Shell Monkey--pct-nav <percent>

Main navigation Events
Set the main navigation event percentage, compatible with middle, back, and menu keys
adb Shell Monkey--pct-majornav <percent>

System navigation Events
Set the system navigation event percentage, HOME, Back, dial, volume keys
adb Shell Monkey--pct-syskeys <percent>

Start Activity Events
Set the percentage of events that start activity
adb Shell Monkey--pct-appswitch <percent>

Infrequently used events
Set percentage of infrequently used events
adb Shell Monkey--pct-anyevent <percent>

Crash events
Ignore crashes and exceptions
adb Shell Monkey--ignore-crashes <event-count>

Timeout events
Ignore Timeout events
adb Shell Monkey--ignore-timeouts <event-count>
If a ANR event occurs, you can view it in your phone
1. Enter the ADB shell command to enter the phone
2. Jump to the ANR directory, cd/data/anr/
3. In the ANR directory, more traces.txt view the error message

Monkey Script
1.dispatchtrackball Command
Trackball Events
Dispatchtrackball (Long Downtime,long Eventide,
int action,float x,float y,float pressure,
Float Size,int metastate,float Xprecision,
float Ypercision,int device,int edgeflags)

Action 0 represents press, 1 for talking, X and y for coordinate points

2.dispatchpointer Command
Click events
Dispatchpointer (Long Downtime,long Eventide,
int action,float x,float y,float pressure,
Float Size,int metastate,float Xprecision,
float Ypercision,int device,int edgeflags)
Action 0 represents press, 1 for talking, X and y for coordinate points

3.dispatchstring Command
Input string Event
Dispatchstring (String text)

4.launchactivity Command
Launch the App
Launchactivity (package,activity)

5.userwait Command
Wait for event
Userwait (1000)

6.dispatchpress Command
Press the key value
dispatchpress (int keycode) #keycode 66 return car Key

Example: Double click to search 100 times
1. Launch the App
2. Click on the Input box
3. Enter Query terms
4. Click on the keyboard to enter
5. Click the Search button
6. Wait for the result to appear
7. Click the Clear button

The phone can't execute scripts on the computer
Push the script to the phone
ADB push mook.script/data/local/tmp/

After executing adb shell monkey-f mook.script 2
The effect does not start the app correctly
(!!!) You need to declare android:exported= "true" in the mainfest manifest file
Allows the activity to be called externally

The biggest difficulty in scripting with monkey script is that there is no debugging capability
There is no screenshot operation

monkeyrunner
1.MonkeyRunnner api- alert
Warning box
void alert (String Message,string title,string oktitle)

2.MonkeyRunner api- waitforconnection
Wait for the device to connect, There are multiple device IDs, which you need to indicate specifically which devices
Waitforconnection (float timeout,string deviceid)

3.MonkeyDevice API- drag
Drag
Drag (tuple start,tuple end, float duration,integer steps)
Start start position
End End Position
Duration gesture Duration
Steps the number of steps in the interpolation point, default

4.MonkeyDevice API- Press
Key
Presses (String Keycode,dictionary type)
KeyCode name, down,up,down_and_up

5.MonkeyDevice API- startactivity
Launches the app
StartActivity (package+ '/' +activity)
6.MonkeyDevice api-touch 
Click
Touch ( Integer x,integer y,integer type)
x coordinate value, y coordinate value
type:down,up,down_and_up

7.MonkeyDevice API- type
Input
Type (String message)

8.MonkeyDevice API- takesnapshot
Screen Cutting
Monkeyimage Takesnapshot ()

9.MonkeyImage API- sameas
Image comparison
Boolean Sameas (monkeyimage other,float percent)

10.MonkeyImage API- writetofile
Save image File
void WriteToFile (String path,string format)

App Stress test Finishing

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.