Monkey is a tool for testing our app through the command line, which can be run in a simulator or on a real machine. It sends a pseudo-random user event stream to the system, enabling stress testing of the positive application. Official introduction: https://developer.android.com/studio/test/monkey.html. Test? Isn't this the job of a test sister? Certainly not, we can not feel the code, we can throw a bug item to the test sister, then we may have to spend some time with the test sister to do N war. We have to write to our code to self-test, self-rated feel OK and then throw to the testing sister let help comprehensive inspection. Self-test of course can not monkey, such as loading the app, according to the process according to the functional East Point Point, see if the program can walk through, there is no crash and other questions. But this is obviously not enough, we have to think of the process of stress testing to destroy, such as continuous testing 10,000 times, if we are people to operate, estimates have been tired. So we have to think of lazy, let automation tools to test us, so we think of monkey.
- The first step: Build the Environment: mainly install and build Java and SDK environment, plainly, for our Android development, as long as the Android development environment, Monkey test environment is basically OK. Refer to: http://www.cnblogs.com/sylovezp/p/3623588.html
- Step two: Prepare the project to be tested, such as an. APK installation package, or a software that is already installed on your phone.
- The third step: Connect the Android test device, can be a simulator, of course, it can also be a mobile phone, the test project through the ADB command Monkey test.
–ADB Monkey test-related commands description:--–
- 1,ADB Install xx.apk: Installs the specified install package apk file into the test device
- 2,ADB Shell Monkey: Sends a stress test to the specified device, number is the count to be tested. The effect of executing this command is to have a finger on your phone. I tried 10,000 times, and it took a while to get my phone back to the effect I thought.
- 3,ADB Shell Monkey-p Pkgname: As with the above effect, just test the specified package name (pkgname) apk.
- Application of 4,monkey Advanced parameters
4.1.throttle parameter: Specify the interval between events
ADB Shell Monkey-throttle:milliseconds is a time value, in milliseconds
4.2.seed parameter: The seed value of the pseudo-random number generator.
ADB Shell monkey-s: If you run monkey again with the same seed value, it will generate the same sequence of events.
4.3.touch: Set Touch events
ADB Shell Monkey-pct-touch: Specifies the percentage of touch events percent
4.4.motion: Set Action Events
ADB Shell monkey-pct-motion: Specifies the percentage of motion events percent
4.5.trackball: Set Trackball Event
ADB Shell Monkey-pct-trackball: Specifies the percentage of trackball events percent
4.6.nav: Navigation Event settings
ADB Shell Monkey-pct-nav: Specifies the percentage of basic navigation events percent
4.7.majornav: Set Primary navigation events
ADB shell Monkey-pct-majornav: Set main navigation event percentage percent, compatible middle key, return key, menu button
4.8.syskeys: Set Event
ADB shell Monkey-pct-syskeys: Sets the percentage of system events percent, such as home,back, dialing and volume adjustment events.
4.9.appswitch: Start Activity Event
ADB shell Monkey-pct-appswitch: Sets the percentage of events that start activity percent
4.10.anyevent: Infrequently used event settings
ADB shell monkey-pct-anyevent: Set the percentage of infrequently used events
4.11.crashes: Program Crash event settings
ADB shell monkey-ignore-crashes: Ignore crashes and exception events
4.12.timeouts: Timeout Event settings
ADB shell monkey-ignore-timeouts: Ignore timeout events
After introducing some common settings, start the basic Monkey tour:
The first step: Prepare to test the APK, as I want to test the APK, placed on my Computer D-disk:
The second step: Keep the test equipment (mobile phone) connected to the computer, this is not.
Step three: Install the apk you want to test into your phone using the adb install command, and of course you can test the APK already installed on your phone.
Fourth step: Use the basic test command above to monkey test the installed monkey_test.apk.
ADB shell Monkey-p com.xx.xx 10 refers to the test 10 times, as below, during the run you can see the APK being operated on the phone.
The fifth step, according to your own needs, use other commands to test the APK:
For example, through the ADB shell monkey-v-p com.xx.xx 100来 simple output test information,
The percentage above is the ratio of the corresponding event, as well as other related information such as touch events.
Other test commands are not posted, you can use the relevant commands when you want to test your work.
There are more than n detailed references on the Internet, such as http://blog.csdn.net/zm2714/article/details/7977930.
Android Monkey Test Primer (pick)