Fastbot_Android稳定性测试

本地接入

  • 下载项目

GitHub - bytedance/Fastbot_Android: Fastbot(2.0) is a model-based testing tool for modeling GUI transitions to discover app stability problemsFastbot(2.0) is a model-based testing tool for modeling GUI transitions to discover app stability problems - GitHub - bytedance/Fastbot_Android: Fastbot(2.0) is a model-based testing tool for modeling GUI transitions to discover app stability problemshttps://github.com/bytedance/Fastbot_Android

  •  我使用的是逍遥模拟器,CPU型号x86_64

adb push E:\Fastbot_Android-main\libs\x86_64 /data/local/tmp 

  • 把jar文件导入手机数据库

adb push E:\Fastbot_Android-main\fastbot-thirdpart.jar /sdcard

adb push E:\Fastbot_Android-main\framework.jar /sdcard

adb push E:\Fastbot_Android-main\monkeyq.jar /sdcard

启动fastbot

adb shell CLASSPATH=/sdcard/monkeyq.jar:/sdcard/framework.jar:/sdcard/fastbot-thirdpart.jar exec app_process /system/bin com.android.commands.monkey.Monkey -p xxx --running-minutes 1 --bugreport --output-directory /sdcard/log --throttle 500 -v -v
  • 参数说明
  1. -s 设备号 多个设备需要指定设备号,单独设备无需此-s参数
  2. -p 包名 遍历app的包名,-p+包名
  3. --agent reuseq 遍历模式,无需更改
  4. --running-minutes 遍历时长(分钟) # 遍历时间:--running-minutes 时间
  5. --throttle 事件频率 遍历事件频率,建议为500-800
  6. 可选参数
    • --bugreport 崩溃时保存bug report log
    • --output-directory /sdcard/xxx log/crash 另存目录

  •  结果分析
  1. Crash、ANR 捕获
    • 捕获到Java Crash、ANR、Nativie Crash会以追加方式写入/sdcard/crash-dump.log文件
    • 捕获的Anr 同时也会写入 /sdcard/oom-traces.log 文件
  2. Activity覆盖率统计
    • 正常跑完Fastbot会在当前shell中打印totalActivity(总activity列表),ExploredActivity(遍历到的activity列表)以及本次遍历的总覆盖率
    • 总覆盖率计算公式: coverage = testedActivity / totalActivities * 100

 

 app测试时,crash保存于crash-dump.log中,同时在/sdcard/log目录下有详细的崩溃日志

  •  详细教程参考中文文档

Fastbot_Android/handbook-cn.md at main · bytedance/Fastbot_Android · GitHubFastbot(2.0) is a model-based testing tool for modeling GUI transitions to discover app stability problems - Fastbot_Android/handbook-cn.md at main · bytedance/Fastbot_Androidhttps://github.com/bytedance/Fastbot_Android/blob/main/handbook-cn.md

 高速截图及打印xml结构

保存测试过程中的截图和打印xml结构

适用需求: 观察测试过程中的截图

  1. 高速截图
    • 在PC 端新建 max.config文件,增加以下属性
    • max.takeScreenshot = true
    • max.takeScreenshotForEveryStep = true
    • max.saveGUITreeToXmlEveryStep =true
    • 将 max.config 文件push到手机端sdcard中 , 目录必须为sdcard
      adb push max.config /sdcard 
      
    • 目录默认保存为手机端sdcard中,如需改变保存位置,在执行命令末尾添加 --output-directory 指定路径, --throttle 参数要 >200 才会截图

 

自定义事件序列

手动配置Activity的路径(UI自动化用例)

适用需求: 场景覆盖不全,通过人工配置到达 Fastbot 遍历不到的场景, 或自定义操作序列(例如前置登录等)

  1. 在pc端新建 max.xpath.actions 文件(文件名称不可更改)

  2. 编写事件序列配置(case):

    ​​​​​​​
    • prob:发生概率,"prob":1,代表发生概率为100%
    • activity:所属场景,详见:三.获取当前页面所属的Activity
    • times:重复次数,默认为1即可
    • actions:具体步骤的执行类型
    • throttle:action间隔事件(ms)
    action支持以下类型,必须大写​​​​​​​
    1. SCROLL_RIGHT_LEFT:从右向左滑动
    2. SCROLL_LEFT_RIGHT:从左向右滑动
    3. SCROLL_BOTTOM_UP:从下向上滑动
    4. SCROLL_TOP_DOWN:从上向下滚动
    5. BACK:返回
    6. LONG_CLICK:长按
    7. CLICK:点击,想要输入内容在action下补充text,如果有text 则执行文本输入

现新建一个max.xpath.actions文件

{
"prob":1,
"activity":"xxx.main.activity.SettingsActivity",
"actions":[
{
"id":"xxx:id/setting",
"action":"CLICK",
"throttle":500
}
]

 推送到手机

adb push max.xpath.actions /sdcard 

 启动fastbot后,确实点击了设置按钮,成功触发埋的crash!

 常见问题

本地测试时,手机的顶部状态栏找不到了,怎么恢复

adb shell wm overscan reset 为了防止测试时点击到设置,影响测试效果,做的特殊设置

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值