monkey,app稳定性测试

什么是monkey测试

  • 伪随机流的稳定性测试
  • 通俗来说,Monkey 测试即“猴子测试”,是指像猴子一样,不知道程序的任何用户交互方面的知识,就对界面进行无目的、乱点乱按的操作

参数说明

  • -p 包名列表
  • -v 日志详细程度
  • -s 随机数种子
  • -throttle 用户操作时延毫秒
  • -pct-touch <percent> 触摸事件百分比
  • --pct-motion <percent>滑动事件百分比
  • --ignore-crashes 应用奔溃或异常时继续发送事件给系统,直到计数完成
  • action_num 总的操作数量

 问题回溯:根据seed值可复现

日志查看

与开发沟通,主要有以下几种异常

  • 算术异常类:ArithmeticExecption
  • 空指针异常类:NullPointerException
  • 类型强制转换异常:ClassCastException
  • 违背安全原则异常:SecturityException
  • 文件已结束异常:EOFException
  • 文件未找到异常:FileNotFoundException
  • 字符串转换为数字异常:NumberFormatException
  • 操作数据库异常:SQLException
  • 输入输出异常:IOException
  • 崩溃:CRASH
  • 错误:Error

移动应用实例

# 开始时间
start_time = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
# 随机数种子
seed = random.randint(0, 1000)
# 用户操作时延
throttle = random.randint(300, 2000)
# 操作集合
action_dict = '--pct-touch 80 --pct-motion 20'
# 操作总次数
action_nums = random.randint(500, 2000)
# action_nums = 10
# 异常集合
exception_dict = {}

cmd = 'adb -s {} shell monkey -p {} -s {} --throttle {} {} ' \
      '--ignore-crashes -v -v -v {}'.format(self.udid, self.appPackage, seed, throttle, action_dict, action_nums)

# 报告里展示
logout_tmp = subprocess.check_output(cmd).decode('utf-8')
print("monkey日志信息={}".format(logout_tmp))

# 结束时间
end_time = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))

# 异常记录
tmp_list = ['ArithmeticExecption', 'NullPointerException', 'ClassCastException', 'NegativeArrayException',
            'SecturityException', 'EOFException', 'FileNotFoundException', 'NumberFormatException',
            'SQLException', 'IOException', 'CRASH', 'Error']
for i in tmp_list:
    if logout_tmp.count(i):
        exception_dict[i] = logout_tmp.count(i)

# 写库
MysqlHelper('testcenter').monkey_testcase_data_record(package=self.appPackage, seed=seed,
                                                      throttle=throttle, action_dict=action_dict,
                                                      action_nums=action_nums,
                                                      exception_dict=exception_dict,
                                                      start_time=start_time, end_time=end_time)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值