Monkey小白入门篇

一、monkey简介

  中文名:猴子

  职业:压力测试小工具

  用途:对待测Android应用程序进行压力测试,测试app是否会crash

  Android官方描述:

      The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner.

中文翻译:Monkey是一个程序,运行在您的模拟器或设备上,并生成伪随机的用户事件流,如点击,触摸或手势,以及一些系统级事件。 您可以使用Monkey以随机但可重复的方式对您正在开发的应用程序进行压力测试。

  monkey官方文档:https://www.android-doc.com/tools/help/monkey.html

二、monkey的存放路径

  1. monkey程序是Android系统自带的,由java语言写成,在Android文件系统中的存放路径是: /system/framework/monkey.jar
  2. monkey.jar程序是由一个名为“monkey”的Shell脚本来启动执行,shell脚本在Android文件系统中的存放路径是:/system/bin/monkey; 

三、money如何启动

  1. 检查设备连接状态:adb devices
  2. 如果设备未连接,则连接设备:adb connect 127.0.0.1:62001   -- 以夜神模拟器为例
  3. 再次查看设备状态:adb devices
  4. 连接成功后输入命令:adb shell
  5. 输入monkey,启动成功

四、如何强制关闭monkey

  1. adb shell ps  -- 查看全部正在运行的进程
  2. 查找com.android.commands.monkey的进程pid
  3. adb shell kill pid   -- pid为monkey的pid,杀掉monkey进程

五、monkey命令

monkey命令格式:adb shell monkey [options] <event-count>

  1. [options]是指monkey可传入参数;
  2. <event-count>是指伪随机事件数。PS:输入100,表示执行100个伪随机事件,必选项

参考链接:https://www.cnblogs.com/du-hong/p/11169602.html

一行代码一行诗
原文地址:https://www.cnblogs.com/huainanhai/p/11764381.html