Android App stress test
1. Introducing the
monkey tool: It is a tool that can automatically test Android apps. It is necessary to write monkey scripts, run in the monekey runner, simulate human operations, complete app automation tests, and finally deliver app crashes logs to development for app modification.
adb command: control and use the monkey tool on the mobile phone, and also can use adc to complete the installation and uninstallation on the mobile phone.
Monkey Script: Help complete repeated operations
MonkeyRunner: Provides three major APIs
2. Two background questions
1. Why carry out stress testing
Improve product stability;
Improve product retention rate.
2. When to start the stress test
After passing the first round of functional tests;
Carried out at night after get off work.
Three, 7 basic knowledge
1. Manual test scenario and automatic test scenario
According to the theoretical analysis of manual test, it is concluded that the central problem of automatic test is to solve the problem of event flow, and the event flow is the operation or say when the mobile phone is processing the problem Is the running process.
Simulate event flow
2. Introduction to Monkey test tool
1) What is monkey?
Monkey is a tool for sending pseudo-random user events.
2) Where is Monkey?
In our mobile phone system. In order to communicate with it, we need to use ADB.
3) What is ADB?
Android Debug Bridge Android Debug Bridge, soft connection adb, connection between mobile phone and computer
ADB
3. Introduction to MonkeyScript test command collection
1) What is MonkeyScript?
MonkeyScript is a set of commands that can be recognized by Monkey.
MinkeyScript can complete repeated fixed operations.
2) What is MonkeyRunner?
MonkeyRunner provides a series of APIs.
MonkeyRunner can complete simulation events and screenshot operations.
3) What is the difference between Monkey and MonkeyRunner?
Monkey: In adbshell, generate pseudo-random events for users or systems
MonkeyRunner: Define specific commands and event control equipment through API
4)MonkeyRunner APIS
MonkeyRunner: used to connect to a device or simulator
MonkeyDevice: Provides installation and uninstallation of applications, and sends simulated events
MonkeyImage: Complete the operation of image saving and comparison.
5) Test type of MonkeyRunner
Multi-device control
function test
Regression Testing
4. Abnormal test result
CRASH: crash, the application exits abnormally during use
ANR:APPlication Not Responding
ANR situation icon
Four, 6 small practice cases
1. An android stress test practice
Prepare test environment: Android SDK environment, Python environment
Download the Android SDK link: www.android-studio.org
Python download link: https://www.python.org/
If you have any questions about learning Python, learning methods, learning routes, and how to learn efficiently, you can always consult me, or if you lack systematic learning materials, I have been in this industry for a long time, and I think I am more experienced. , Can help you make constructive suggestions, this is my Python exchange qun: 785128166, if you have any questions, please feel free to consult me.
Practice steps:
Step 1: In the mobile phone developer options, select USB debugging.
Icon
Step 2: Confirm that the phone and the computer have been successfully connected, adb devices to confirm.
Icon (mobile phone unique logo name)
Step 3: Install and test APP command: adb install package.apk.
Step 4: Send the pressure command command: adb shell monkey 1000. Means monkey sends 1000 events randomly
Icon
Step 5: Get the APP package name command: adb "logcat | grep START".
Icon
There is also a way to get the package name and process name of the app, refer to step 5 in the following connection, which is relatively simple. (https://www.jianshu.com/p/5cd011bc1a46)
Step 6: Give the specified package pressure command: adb shell monkey -p package 1000
Example: such as deduction for Tencent: adb shell monkey -p com.tencent.mobileqq 1000
Note: Don't do it when the phone is locked, it will report IO exception
Icon
2.Monkey advanced parameter-
throttle practice throttle: specify the interval between events
adb shell monkey --throttle
Illustration (execute 100 events, each event interval is 1000 milliseconds)
3. Monkey advanced parameters-
seed practice seed: specify the seed value of the randomly generated number
Specify a random value, and generate the same operation every time it runs to reproduce a certain situation.
adb shell monkey -s
Icon
4.Monkey advanced parameters-touch practical practice
Touch events: set the percentage of touch events
adb shell monkey --pct-touch
Icon
5.Monkey advanced parameters-other event practice
Action events: set the percentage of action events
adb shell monkey --pct-motion
Icon
Trackball events: set the percentage of trackball events
adb shell monkey --pct-trackball
Basic navigation events: set the percentage of basic navigation events, enter the top, bottom, left, and right of the device
adb shell monkey --pct-nav
Main navigation events: set the percentage of main navigation events, compatible with the middle button, back button, and menu button
adb shell monkey --pct-majornav
System navigation events: set the percentage of system navigation events, HOME, BACK, dial and volume keys
adb shell monkey --pct-syskeys
Start Activity event: set the percentage of events that start Activity
adb shell monkey --pct-appswitch
Uncommon events: set the percentage of uncommon events
adb shell monkey --pct-anyevent
Crash events: Ignore crashes and exceptions
adb shell monkey --ignore-crashes
Timeout event: ignore the timeout event
adb shell monkey --ignore-timeouts
6. Extraction of CRASH abnormal test results.
Practice process:
1. Install apps that can cause crashes
adb install app-debug_crash.apk
2. Execute pressure commands
adb shell monkey -p package name 1000 (execute 1000 times)
3. Extract the exception information of crash
You can send these content to the development
You can use seed to reproduce the above exception
Icon
7. ANR abnormal test results extraction
practice process:
1. Install an app that can cause ANR
adb install app_debug_anr.apk
2. Execute pressure commands
adb shell -p package name 1000