Android稳定性测试利器monkey

󰃭 2016-05-02

#简介

Android的Monkey就是SDK中附带的一个工具,该工具主要用于进行压力测试,现在安卓市场已经变得非常非常庞大。 相对应的安卓测试也变得异常重要,android原生版本从2.1到目前Android N。 本文讲一下安卓测试工具Monkey的常用命令以及使用,可以帮助到想成为安卓测试攻城狮的小伙伴。 ##Monkey的常规类命令 1.$ adb shell monkey -h -h: 同所有命令一样,是一个帮助信息的参数。 2.$ adb shell monkey -v <event-count> -v:增加反馈信息的级别,-v越多日志信息越详细,但是最多只有三个v(⊙o⊙)哦。 ##Monkey的事件类命令

1.$ adb shell monkey -f <scriptfile> <event-count> -f: 测试脚本的存放地址以及脚本名。 例如: $ adb shell monkey -f /mnt/sdcard/test helloword 2.$ adb shell monkey -s <seed> <event-count> -s: 随机生成的seed值,如果使用相同的seed,每次将执行相同的随机事件,可以作为回归测试用。 ##Monkey的约束类命令 1.$ adb shell monkey -p <allowed-package-name> <event-count> -p: 每个-p对应一个包名,可以有多个包名。 例如: $ adb shell monkey -p com.farcore.videoplayer -p com.chnMicro.MFExchange 5000 2.$ adb shell monkey -c <main-category> <event-count> -c: 后接一个或者多个类名。 例如: $ adb shell monkey -c Intent.CATEGORY_LAUNCHER 5000 ##Monkey的调试类命令 一般调试类命令都是和事件类命令以及约束性命令一起使用。 1.$ adb shell monkey -p --dbg-no-events <event-count> –dbg-no-events: monkey将进行初始启动,进入到某个测试Activity中不会进一步生成事件。 2.$ adb shell monkey -p --hprof <event-count> –hprof: 将在monkey时间序列前后立即生成profiliing report。 这边只是对Monkey的及类命令做简单介绍,其实各种命令类型中还有很多可扩展的东西,之后小编在慢慢给大家介绍。有需求的小伙伴也可随时回复进行反馈,大家一起学习。谢谢。