当前位置:网站首页>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 :
边栏推荐
- BUUCTF(web:1-50)
- Summary of SQL injection (I)
- Extend the toolbar of quill editor
- 1.5.3 use tcpdump to observe ARP communication process
- Compatible with Internet Explorer
- How to choose the years of investment in financial products?
- Ctfhub eggs
- Stack and Queue
- Go Concurrency
- Deep analysis of epoll reactor code
猜你喜欢

滲透測試-提權專題

Ranorex Studio 10.1 Crack

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

Detailed summary of float

CTFHUB SSRF

SQL lab range explanation

Summary of SQL injection (I)

Visual studio 2022 interface beautification tutorial

Personalized Federated Learning with Moreau Envelopes
![[relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear](/img/12/d41f8d5abcb61d2632a8b117bf1604.jpg)
[relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear
随机推荐
Everything is an object
Dynamic programming full backpack
Creation and use of MySQL index
What happens when you use "-fno exceptions", "new T"- With “-fno-exceptions”, what happens with “new T”?
Conflict between v-mode and v-decorator in Ant Design
[pan Wai 1] Huawei computer test
1.5.3 use tcpdump to observe ARP communication process
Prototypical Networks for Few-shot Learning
What if win11 Bluetooth fails to connect? Solution of win11 Bluetooth unable to connect
Go Context - Cancelation and Propagation
Ranorex Studio 10.1 Crack
Stack and Queue
Personalized Federated Learning with Moreau Envelopes
Deep analysis of recursion in quick sorting
Implementation of websocket long connection by workman under laravel
Object creation and invocation code example
Example of dynamic programming 3 leetcode 55
CUDA compilation error
Double recursion in deep analysis merge sort
February 20ctf record