当前位置:网站首页>Monkey test of APP automation
Monkey test of APP automation
2022-06-25 05:24:00 【Zhang San*】
Catalog
- One 、 Why do it monkey test
- Two 、 What is? monkey test
- 3、 ... and 、monkey Test environment preparation
- Four 、monkey How to test
- One 、monkey Common commands
- see monkey Parameters adb shell monkey
- Carry out... On the whole machine 200 Event operation :adb shell monkey 200
- - p Specify the application package name :adb shvell monkey -p com.xueqiu.android 1000
- - ignore-crashes : Ignore the crash
- - ignore-timeouts: Ignore timeout
- - ignore-security-exceptions : Ignore security certificate issues
- - v Specify the log level :adb shell monkey -p com.xueqiu.android -v 1000
- - s Appoint seed value :adb shell monkey -p com.xueqiu.android -s 1235 1000
- -throttle MILLISEC Delay time
- 5、 ... and 、 Result analysis :
- 6、 ... and 、 complete monkey Script :

One 、 Why do it monkey test
background : With the rise of mobile Internet , More and more APP Into our lives , Such as WeChat 、 Tiktok 、 Taobao, etc. , These are commonly used APP Generally, there are a large number of users 、 Long online time , Such as daily activity of Tiktok 8 Billion , Online time average 3 Start in an hour , So I'm testing APP In the process of , In addition to considering the accuracy of the function , Compatibility, etc , It needs to be taken into account APP The stability of . On the market , It is generally used monkey Tools to test Android APP The stability of ,iOS The stability of is generally provided by the open source community iOSmonkey To test the stability .
monkey Test node time : APP Basically stable function , Before pre release and acceptance
Commonly used tools :monkey 、Python 、git、gitlab、Jenkins
Two 、 What is? monkey test
monkey test Android A means of automation ,monkey It's very simple , It is to use scripts to simulate a series of common user operations , Such as setting screen brightness 、 Adjust sound 、 slide 、 Gesture input, etc , The whole process is pseudo-random , Randomness is reflected in the randomness of actions , Pseudo representations can be passed through -s namely seed value To reproduce the last operation .
3、 ... and 、monkey Test environment preparation
One 、 Environmental preparation
install jdk1.8, To add to path
install Android SDK , To add to path
Verify that the environment is installed successfully :
jdk :
SDK:
If as above , Display the corresponding version number SDK and jdk Installation successful
Two 、 Connecting device
mobile phone :
- Connect your phone with a data cable
- Turn on the mobile developer mode , open USB Debugging function
- stay DOS Window type adb devices , If the equipment number appears , The connection is successful
Simulator :
- Turn on the simulator
- DOS Window input command :adb connect IP:port, Such as adb connect 127.0.0.1:7555
- stay DOS Window type adb devices , If the equipment number appears , The connection is successful
Take the simulator for example :
PS: If you don't know the simulator port, you can check it on the official website , After the real machine is connected , Direct use adb devices that will do
Four 、monkey How to test
One 、monkey Common commands
see monkey Parameters adb shell monkey
C:\Users\zyd>adb shell monkey
usage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...]
[-c MAIN_CATEGORY [-c MAIN_CATEGORY] ...]
[--ignore-crashes] [--ignore-timeouts]
[--ignore-security-exceptions]
[--monitor-native-crashes] [--ignore-native-crashes]
[--kill-process-after-error] [--hprof]
[--pct-touch PERCENT] [--pct-motion PERCENT]
[--pct-trackball PERCENT] [--pct-syskeys PERCENT]
[--pct-nav PERCENT] [--pct-majornav PERCENT]
[--pct-appswitch PERCENT] [--pct-flip PERCENT]
[--pct-anyevent PERCENT] [--pct-pinchzoom PERCENT]
[--pct-permission PERCENT]
[--pkg-blacklist-file PACKAGE_BLACKLIST_FILE]
[--pkg-whitelist-file PACKAGE_WHITELIST_FILE]
[--wait-dbg] [--dbg-no-events]
[--setup scriptfile] [-f scriptfile [-f scriptfile] ...]
[--port port]
[-s SEED] [-v [-v] ...]
[--throttle MILLISEC] [--randomize-throttle]
[--profile-wait MILLISEC]
[--device-sleep-time MILLISEC]
[--randomize-script]
[--script-log]
[--bugreport]
[--periodic-bugreport]
[--permission-target-system]
COUNT
C:\Users\zyd>
Carry out... On the whole machine 200 Event operation :adb shell monkey 200

- p Specify the application package name :adb shvell monkey -p com.xueqiu.android 1000

- ignore-crashes : Ignore the crash
While the script is running , In general, you will encounter a crash ,monkey It will end , Plus ignore parameters , You can make the script run normally , And record the time of the crash and the detailed reason .
- ignore-timeouts: Ignore timeout
Ignore problems that should be caused by timeouts during scripting
- ignore-security-exceptions : Ignore security certificate issues
Ignore problems that should be caused by security certificate problems in the script process
- v Specify the log level :adb shell monkey -p com.xueqiu.android -v 1000
The minimum level is -v
The highest level is -v -v -v
Due to the large number of logs , Generally, redirection is used to output log information
- s Appoint seed value :adb shell monkey -p com.xueqiu.android -s 1235 1000
seed Values are also called sequence values , Or seed value , Often used to reproduce problems , Fruit twice seed equally , Then it means that the sequence of actions simulated by the script is the same , But there is no guarantee that the objects of the operation are the same .
-throttle MILLISEC Delay time
Time between events , Work is generally 450ms
Number of events at work :30w Time , Delay time :450ms , Script execution time 8-10 Hours
5、 ... and 、 Result analysis :
// Monkey finished Express monkey End of test

Common causes of failure :
View the logs by keyword search bug
1.crash Run away
crash Submit bug when , add to logcat Just log .
2.ANR No response
ANR Submit bug when ,adb shell 、data/anr/traces.txt, Need to submit traces.txt file .
monkey Abnormal interruption
- Abnormal shutdown of mobile phone
- The phone restarts abnormally
- mobile phone CPU Abnormal temperature, etc
bug Submit
title :【monkey】【crash/ restart /…】APP In execution monkey Test occurrence crash/ restart /…
Repeat step :
- Environmental Science
- command
- View results
Expected results : monkey Execution without exception
The actual result : monkey In the process of execution crash
By keyword analysis logcat journal , Such as ANR/fatal/reboot/OOM/exception
# Redirect download logcat journal
adb logcat -v time >E:\APPLOG\logcat.txt
adb shell monkey -p com.xueqiu.android - 300
6、 ... and 、 complete monkey Script :
adb shell monkey --throttle 450 --ignore-security-exceptions --ignore-crashes --ignore-timeouts -v -v -v -p com.xueqiu.android 200 >E:\APPLOG\logcat.txt
logcat The documents are as follows :
边栏推荐
- Read the general components of antd source code
- How to choose the years of investment in financial products?
- Five simple data types of JS
- 2.20 learning content
- JS function to realize simple calculator
- Dynamic programming example 1 leetcode 322 coin change
- Mysql interactive_ Timeout and wait_ Timeout differences
- Small sample learning data set
- JS verification code input number auto skip
- Svg code snippet of loading animation
猜你喜欢

How to install the blue lake plug-in to support Photoshop CC 2017

Array introduction plus example 01

HR took the initiative to raise the salary of the test lady. How did she do it?

Penetration test - right raising topic

Use js to simply implement the apply, call and bind methods

Everything is an object

2022.1.25

Various pits encountered in the configuration of yolov3 on win10

Deep analysis of recursion in quick sorting

DOM document object model (I)
随机推荐
Stack and Queue
Rce code execution & command execution (V)
A brief talk on media inquiry
Bind simulation, key points of interpreting bind handwritten code [details]
Basic knowledge of web pages (URL related)
Create dynamic array
I got to know data types and function variables for the first time. I learned data types and function variables together today and yesterday, so I saved them in the first issue to record.
Customize the console plot result style
Large number operation (capable of square root, power, permutation and combination, logarithm and trigonometric value)
Double recursion in deep analysis merge sort
Five simple data types of JS
CSRF (Cross Site Request Forgery) &ssrf (server request forgery) (IV)
Array and simple function encapsulation cases
2.20 learning content
How to open the DWG file of the computer
API interface management setup -eolinker4.0
Edge loss interpretation
Various pits encountered in the configuration of yolov3 on win10
3.2.3 use tcpdump to observe TCP header information (supplement common knowledge of TCP protocol)
CTFHUB SSRF