adb shell monkey command combat analysis record - command and debugging column

monkey automated testing commands

The monkey command is a utility for stress testing applications. This command randomly sends a specified number of user event streams (key input, touch screen, gestures, etc.) to the APP interface. monkey is a word for a monkey, as the name implies, it means jumping up and down on the mobile phone APP and typing in random words continuously.

Grammar format:
Usage: monkey [options]

options parameter:
-p <allowed_package> # Allow testing software package, you can specify multiple -p parameters to support multiple software packages
-c <main_category> # main category, you can specify multiple -c parameters

--ignore-crashes                # 忽略崩溃, 继续执行事件
--ignore-native-crashes         # 忽略 native 崩溃, 继续执行事件
--ignore-timeouts               # 忽略超时, 继续执行事件
--ignore-security-exceptions    # 忽略安全异常, 继续执行事件
--monitor-native-crashes        # 监控 native 崩溃

--kill-process-after-error      # 发生错误时杀死进程
--hprof
--match-description <text>

--pct-touch <percent>           # 触摸事件百分比, 例如指定触摸事件比例为 30%, 格式为: --pct-touch 30
--pct-motion <percent>          # 手势动作事件百分比, 所有事件百分比之和不能超过 100%
--pct-trackball <percent>       # 轨迹事件百分比 
--pct-syskeys <percent>         # 系统按键事件百分比
--pct-nav <percent>             # 基本导航事件百分比
--pct-majornav <percent>        # 主要导航事件百分比
--pct-appswitch <percent>       # APP 切换事件百分比
--pct-flip <percent>            # 弹事件百分比
--pct-anyevent <percent>        # 其他事件百分比
--pct-pinchzoom <percent>       # 缩放(捏)事件百分比
--pct-permission <percent>      # 权限事件百分比

--pkg-blacklist-file <file>     # 
--pkg-whitelist-file <file>     # 

--wait-dbg                      # 如果 adb 断开, 等待 adb 连接, 直到 adb 恢复连接后继续执行 monkey
--dbg-no-events                 
--setup scriptfile
-f <scriptfile>                 # 指定用于测试的脚步文件, 可以指定多个 -f 参数
--port <port>
-s <seed>                       # 产生伪随机事件的种子, 相同的 -s 产生的事件流相同, 格式(可指定多个-s): -s 1
-v                              # 反馈信息级别, -v 越多个, 输如的日志信息越详细, 最多支持 3 个 -v
--throttle <ms>                 # 事件之间的间隔(单位为毫秒), 例如 200毫秒 的格式: --throttle 200
--randomize-throttle            # 随机事件间隔时间
--profile-wait <ms>             # 
--device-sleep-time <ms>        # 
--randomize-script              #
--script-log                    # 
--bugreport                     # 
--periodic-bugreport            # 
--permission-target-system      # 

Command example:

Randomly send 10,000 events on the app com.example.app

monkey -p com.example.app 10000

The event interval is 10 milliseconds, and 10000 events are randomly sent

monkey -p com.example.app --throttle 10 10000

Touch screen events account for 30%, gesture events account for 10%, send 10000 events

monkey -p com.example.app --pct

Guess you like

Origin blog.csdn.net/weixin_44380181/article/details/129698223