Android 性能测试_Monkey 实践【转】
2016-02-20 18:30
429 查看
参考资料:
1. Monkey测试策略:https://testerhome.com/topics/597
2. Android Monkey测试详细介绍:http://www.jikexueyuan.com/course/1619.html
3. Monkey总结:https://testerhome.com/topics/3517
1. 目前做的是银行APP,另下载安装3个第三方手机银行的APP以方便对比
2. 将四个APP的包名添加到白名单,同时测试这四个APP
3. 运行Monkey,将日志记录到手机中
4. 测试过程中记录APP占用内存和CPU的变化
5. 测试完毕后查看Monkey日志,将内存和CPU数据用图表来分析。
疑问:
1. 此APP是需要登录的,测试过程中退出账号后无法再进入程序内部,不知道其他公司是如何避免的?
答:经咨询,目前常用两种做法:1. 让开发将退出按键给屏蔽掉 2.点击登录不检测账号和密码
针对不同APP都有什么策略还不是很清楚,比如延时、事件数量、事件比例 等设置成多少合适?
运行Monkey
根据sandman的建议,优化命令:
2>&1的语法参考Linux的解释:http://blog.csdn.net/ithomer/article/details/9288353
注意:
命令adb shell top -n 1 | findstr %package1% 返回三行信息,暂未处理:
将记录的内存数据插到Excel表中对比查看
将记录的CPU数据插到Excel表中对比查看
1. Monkey测试策略:https://testerhome.com/topics/597
2. Android Monkey测试详细介绍:http://www.jikexueyuan.com/course/1619.html
3. Monkey总结:https://testerhome.com/topics/3517
测试步骤
思路1. 目前做的是银行APP,另下载安装3个第三方手机银行的APP以方便对比
2. 将四个APP的包名添加到白名单,同时测试这四个APP
3. 运行Monkey,将日志记录到手机中
4. 测试过程中记录APP占用内存和CPU的变化
5. 测试完毕后查看Monkey日志,将内存和CPU数据用图表来分析。
疑问:
1. 此APP是需要登录的,测试过程中退出账号后无法再进入程序内部,不知道其他公司是如何避免的?
答:经咨询,目前常用两种做法:1. 让开发将退出按键给屏蔽掉 2.点击登录不检测账号和密码
针对不同APP都有什么策略还不是很清楚,比如延时、事件数量、事件比例 等设置成多少合适?
一、运行Monkey
将白名单push到手机adb push E:\01_AutomationTest\01_Monkey\05_NbBank\whitelist.txt data/local/tmp/
运行Monkey
adb shell monkey --pkg-whitelist-file /data/local/tmp/whitelist.txt --throttle 500 -s 100 --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v -v -v 15000 > /mnt/sdcard/monkey_test.txt &
根据sandman的建议,优化命令:
adb shell monkey --pkg-whitelist-file /data/local/tmp/whitelist.txt --throttle 500 -s 100 --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v -v -v 15000 1> /mnt/sdcard/monkey_test.txt 2>&1 &
2>&1的语法参考Linux的解释:http://blog.csdn.net/ithomer/article/details/9288353
二、内存检测
内存检测用批处理脚本记录,约5秒记录一次:@echo off &color 0a&setlocal enabledelayedexpansion&title %~n0 ::@mode con lines=18 cols=50 set package1=com.nbbank set package2=cn.com.spdb.mobilebank.per set package3=com.chinamworld.bocmbci set package4=com.cmbchina.ccd.pluto.cmbActivity adb shell dumpsys meminfo %package1% | findstr "Pss" > ./meminfo_1.txt adb shell dumpsys meminfo %package1% | findstr "Pss" > ./meminfo_2.txt adb shell dumpsys meminfo %package1% | findstr "Pss" > ./meminfo_3.txt adb shell dumpsys meminfo %package1% | findstr "Pss" > ./meminfo_4.txt :start adb shell dumpsys meminfo %package1% | findstr "TOTAL" >> ./meminfo_1.txt adb shell dumpsys meminfo %package2% | findstr "TOTAL" >> ./meminfo_2.txt adb shell dumpsys meminfo %package3% | findstr "TOTAL" >> ./meminfo_3.txt adb shell dumpsys meminfo %package4% | findstr "TOTAL" >> ./meminfo_4.txt echo. echo. ping -n 5 127.1>nul goto start
三、记录CPU百分比
@echo off &color 0a&setlocal enabledelayedexpansion&title %~n0 ::@mode con lines=18 cols=50 set package1=com.nbbank set package2=cn.com.spdb.mobilebank.per set package3=com.chinamworld.bocmbci set package4=com.cmbchina.ccd.pluto.cmbActivity adb shell top -n 1 | findstr "PID" > ./cupInfo_1.txt adb shell top -n 1 | findstr "PID" > ./cupInfo_2.txt adb shell top -n 1 | findstr "PID" > ./cupInfo_3.txt adb shell top -n 1 | findstr "PID" > ./cupInfo_4.txt :start adb shell top -n 1 | findstr %package1% >> ./cupInfo_1.txt adb shell top -n 1 | findstr %package2% >> ./cupInfo_2.txt adb shell top -n 1 | findstr %package3% >> ./cupInfo_3.txt adb shell top -n 1 | findstr %package4% >> ./cupInfo_4.txt echo. echo. ping -n 5 127.1>nul goto start
注意:
命令adb shell top -n 1 | findstr %package1% 返回三行信息,暂未处理:
C:\Users\Stphen>adb shell top -n 1 | findstr com.nbbank 25353 0 1% S 23 543128K 66260K bg u0_a193 com.nbbank 25385 1 0% S 3 11480K 1368K fg u0_a193 com.nbbank 25383 0 0% S 3 11692K 4180K fg u0_a193 com.nbbank
四、结果分析
Crash、ANR、Force close暂时没发现,以后补上将记录的内存数据插到Excel表中对比查看
将记录的CPU数据插到Excel表中对比查看
相关文章推荐
- Android Monkey 测试策略【转】
- Android&java的成长之路之四(自定义字母索引)
- Android项目使用support v7时遇到的各种问题
- Android Widget学习笔记
- android 5.1预置apk
- Android 启动Activity的方式
- Android的通讯员——notification
- Android笔记---TableLayout表格布局
- android-studio 安装使用
- Android笔记---RelativeLayout相对布局
- Android Fragment 真正的完全解析
- android简单实例-----------------使用SQLiteOpenHelper以及SQLiteDatabase
- 第7章 Android动画深入浅析
- android变色状态栏
- 有了Font Awesome,再也不担心没图标用了----Font Awesome字体图标在android中的使用
- android-代码修改TextView中部分某段文字的颜色
- android.support.v4.widget.DrawerLayout使用
- Android中Word转Html
- Android高效加载大图、多图解决方案,有效避免程序OOM
- Android px、dp、sp之间相互转换