1、操作命令如下
a、把monkey进程过滤出来 b、执行kill命令,杀死指定monkey脚本
2、基本命令结构
adb shell monkey [options] <event-count>
[options]
:Monkey工具的各种选项和参数。<event-count>
:Monkey工具将生成的事件总数。
3、常用参数及其说明
-
-p <package>
- 仅向指定的应用程序包发送事件。可以多次使用该选项来测试多个应用程序。
adb shell monkey -p com.example.myapp -p com.example.anotherapp -v 500
-
--pkg-whitelist-file <file>
- 指定一个包含包名的白名单文件。只有在白名单中的应用程序才会接收事件。
adb shell monkey --pkg-whitelist-file /sdcard/whitelist.txt -v 500
-
--pkg-blacklist-file <file>
- 指定一个包含包名的黑名单文件。黑名单中的应用程序不会接收事件。
adb shell monkey --pkg-blacklist-file /sdcard/blacklist.txt -v 500
-
-v
- 指定详细级别。可以使用一次或多次来增加详细级别。共有三个级别:
-v
:提供最少的详细信息。-v -v
:提供更多的详细信息。-v -v -v
:提供最多的详细信息,包括每个事件的详细日志。
adb shell monkey -v 1000
- 指定详细级别。可以使用一次或多次来增加详细级别。共有三个级别:
-
--throttle <milliseconds>
- 在每个事件之间插入固定的延迟时间(以毫秒为单位)。
adb shell monkey --throttle 500 -v 1000
-
-s <seed>
- 指定一个种子值,用于初始化随机数生成器。使用相同的种子可以复现测试。
adb shell monkey -s 12345 -v 1000
-
--ignore-crashes
- 忽略应用程序崩溃,不中止测试。
adb shell monkey --ignore-crashes -v 1000
-
--ignore-timeouts
- 忽略应用程序无响应(ANR)错误,不中止测试。
adb shell monkey --ignore-timeouts -v 1000
-
--ignore-security-exceptions
- 忽略权限错误,不中止测试。
adb shell monkey --ignore-security-exceptions -v 1000
-
--monitor-native-crashes
- 监控并报告本地代码崩溃(如C/C++崩溃)。
adb shell monkey --monitor-native-crashes -v 1000
-
--kill-process-after-error
- 在应用崩溃或出错后杀死应用进程。
adb shell monkey --kill-process-after-error -v 1000
-
--hprof
- 在每次发生异常时生成堆栈快照(hprof 文件)。
adb shell monkey --hprof -v 1000
-
--pct-touch <percent>
- 指定触摸事件的百分比。默认值为 15%。
adb shell monkey --pct-touch 20 -v 1000
-
--pct-motion <percent>
- 指定滑动事件的百分比。默认值为 10%。
adb shell monkey --pct-motion 20 -v 1000
-
--pct-trackball <percent>
- 指定轨迹球事件的百分比。默认值为 15%。
adb shell monkey --pct-trackball 5 -v 1000
-
--pct-syskeys <percent>
- 指定系统按键事件的百分比。默认值为 2%。
adb shell monkey --pct-syskeys 5 -v 1000
-
--pct-nav <percent>
- 指定导航事件的百分比。默认值为 25%。
adb shell monkey --pct-nav 10 -v 1000
-
--pct-majornav <percent>
- 指定主要导航事件的百分比。默认值为 15%。
adb shell monkey --pct-majornav 20 -v 1000
-
--pct-appswitch <percent>
- 指定应用程序切换事件的百分比。默认值为 2%。
adb shell monkey --pct-appswitch 5 -v 1000
-
--pct-anyevent <percent>
- 指定其他事件的百分比。默认值为 1%。
adb shell monkey --pct-anyevent 10 -v 1000
欢迎点赞|关注|收藏|评论,您的肯定是我创作的动力