Maxim-可自定义的Monkey测试工具(Android)

Maxim 基于monkey做的二次开发,相比原始monkey,新增如下功能
  1. 多种随机测试模式:dfs(深度遍历) mix模式(monkey随机测试+控件识别) troy模式(按照控件选择器进行遍历)
  2. 可进行执行时长设定
  3. 可以自定义activity黑白名单
  4. 兼容多个Android版本
  5. 防跳出,防休眠,防假死

Maxim

使用方法

  1. adb push framework.jar monkey.jar文件到 /sdcard 文件夹中
  2. 执行:adb shell CLASSPATH=/sdcard/monkey.jar:/sdcard/framework.jar exec app_process /system/bin tv.panda.test.monkey.Monkey -p com.panda.videoliveplatform --uiautomatormix --running-minutes 60
 

参数说明:

  1. tv.panda.test.monkey.Monkey 主调入口  无需修改
  2. -p com.panda.videoliveplatform  待测appid
  3. 策略模式

    --uiautomatormix 混合模式(70%控件解析随机点击,其余30%按原Monkey事件概率分布) 
    --pct-uiautomatormix n 可自定义混合模式中控件解析事件概率
    demo:
    [  {
    "prob": 1,
    "activity": "com.sjk.userattribute.login.PwdLoginActivity",
    "actions": [
      {
        "xpath": "//*[@resource-id='com.sjk.android:id/et_phone']",
        "action": "INPUTTEXT",
        "text": "15154111005",
        "index": 0,
        "throttle": 500
      },
      {
        "xpath": "//*[@resource-id='com.sjk.android:id/et_pwd']",
        "action": "INPUTTEXT",
        "text": "123456",
        "index": 0,
        "throttle": 500
      },
      {
        "xpath": "//*[@resource-id='com.sjk.android:id/tv_login']",
        "index": 0,
        "action": "CLICK",
        "throttle": 500
      }
    ]
  },
]
--uiautomatordfs DFS深度遍历算法(优化版)(注 Android5不支持dfs) 
--uiautomatortroy Troy模式 
 配置 max.xpath.selector troy控件选择子来定制自有的控件选择优先级,max.xpath.selector 需要push 到/sdcard/
demo:
[
  {
    "firstList": [
      {
        "xpath": "//*[contains(@text,'绝地求生')]"
      }
    ],
    "selectList": [
      {
        "xpath": "//*[@clickable='true']"
      },
      {
        "xpath": "//*[@clickable='true']//*[contains(name(),'Text')]"
      },
      {
        "xpath": "//*[@clickable='true']//*[contains(name(),'Button')]"
      },
      {
        "xpath": "//*[@clickable='true']//*[contains(name(),'Image')]"
      }
    ],
    "lastList": [
      {
        "xpath": "//*[../*[@selected='true']]"
      },
      {
        "xpath": "//*[../../*/*[@selected='true']]"
      },
      {
        "xpath": "//*[../../*/*[@selected='true'] and contains(@resource-id,'tab_')]"
      },
      {
        "xpath": "//*[contains(@resource-id,'HorizontalScrollView')]"
      }
    ],
    "blackList": [
      {
        "xpath": "//*[contains(@resource-id,'wrapper_in_custom_title_bar')]//*[contains(@resource-id,'right_button')]"
      },
      {
        "xpath": "//*[contains(@resource-id,'share')]"
      }
    ]
  }
]
4. 执行时长 --running-minutes 60        执行60分钟monkey场景细粒度控制
5. --act-whitelist-file  /sdcard/awl.strings    自定义Activity白名单
 

Appetizer

 

 

maxim相较于原始的monkey,变得相对智能,可以有效减少无用的点击操作,另外我还发现了一个桌面版的Android移动端测试工具,那就是Appstizer

 

它集成了apk包管理,设备管理,自动化测试等功能,为Android端的测试提供了便利。

 

 

原文地址:https://www.cnblogs.com/dreamyu/p/11716913.html