Monkey 命令

Monkey命令行工具:

    可以运行在模拟器里或实际设备中。它向系统发送伪随机的用户事件流,实现对正在开发的应用程序进行压力测试。Monkey包括许多选项,它们大致分为四大类:

基本配置 选项,如设置尝试的事件数量。

运行约束选项,如设置只对单独的一个包进行测试。

事件类型 和频率。

调试选项。

1) 参数:  -p

参数-p用于约束限制,用此参数指定一个或多个包(Package,即App)。指定包之后,Monkey将只允许系统启动指定的APP。如果不指定包,Monkey将允许系统启动设备中的所有APP。

* 指定一个包: adb shell monkey -p com.htc.Weather  100

说明:com.htc.Weather为包名,100是事件计数(即让Monkey程序模拟100次随机用户事件)。

* 指定多个包:adb shell monkey -p com.htc.Weather –p com.htc.pdfreader  -p com.htc.photo.widgets 100

* 不指定包:adb shell monkey 100

 说明:Monkey随机启动APP并发送100个随机事件。

* 要查看设备中所有的包,在CMD窗口中执行以下命令:

  >adb shell

  #cd data/data

  #ls

实验三:

1. 指定包点:adb shell monkey -p  com.sky.jisuanji  100

2. 不指定包:adb shell monkey 100

3. 点击今日头条:adb shell monkey -p  com.ss.android.article.news 100

原文地址:https://www.cnblogs.com/alldw/p/6540229.html