Android 自动化测试
来源:互联网 发布:苹果笔记本装mac系统 编辑:程序博客网 时间:2024/06/07 12:21
一、基本概念
自动化测试就是模拟人工测试,例如点击按钮,下滑,点击Menu,退出,这一系列的动作都由代码实现。这样的优点主要是可以反复执行很多次,来观察程序是否出现异常。
二、开源框架
主要是robotium,网站是http://code.google.com/p/robotium/
中文网站http://www.robotium.cn/
三、搭建测试环境,并运行第一个自动化测试代码流程,参考:
http://www.robotium.cn/archives/210
四、模仿上下左右滑动,参考
http://blog.softteco.com/2011/02/touch-hold-swipe-release-gesture.html
五、模拟下滑,代码:
private void scrollDown() {Instrumentation inst = getInstrumentation();long downTime = SystemClock.uptimeMillis();// event time MUST be retrieved only by this way!long eventTime = SystemClock.uptimeMillis();// Just init your variables, or create your own coords logic :)float xStart = 200;float yStart = 900;// simulating thick finger touchfloat x0 = 200;float y0 = 900;float x9 = 200;float y9 = 100;// release finger, logically to use coords from last moventfloat x10 =200;float y10 = 100;try {// sending event - finger touched the screenMotionEvent event = MotionEvent.obtain(downTime, eventTime,MotionEvent.ACTION_DOWN, xStart, yStart, 0);inst.sendPointerSync(event);// sending events - finger is moving over the screeneventTime = SystemClock.uptimeMillis();event = MotionEvent.obtain(downTime, eventTime,MotionEvent.ACTION_MOVE, x0, y0, 0);inst.sendPointerSync(event);event = MotionEvent.obtain(downTime, eventTime,MotionEvent.ACTION_MOVE, x9, y9, 0);inst.sendPointerSync(event);// release finger, gesture is finishedevent = MotionEvent.obtain(downTime, eventTime,MotionEvent.ACTION_UP, x10, y10, 0);inst.sendPointerSync(event);} catch (Exception ignored) {//Log.d("gcy111", "run");}}
0 0
- [android]android自动化测试
- [android]android自动化测试
- [android]android自动化测试
- [android]android自动化测试
- android 自动化测试
- Android自动化测试初探
- Android自动化测试初探
- Android 自动化测试
- Android自动化测试解决方案
- android 自动化测试 monkeyrunner
- Android 手机自动化测试
- Android自动化测试
- android 自动化测试 monkey
- Android 自动化测试初探
- Android自动化测试解决方案
- Android自动化测试初探
- Android自动化测试工具
- android自动化测试技术
- 论go语言中goroutine的使用
- __block typeof 编译错误解决
- 转 C#操作Excel(2)-- 打开-读取Excel文档
- 黑马程序员-----IO之打印流
- 无辜的goroutine
- Android 自动化测试
- SqlException只报Number怎么办?
- JSP脚本中的九大内置对象详解(上)
- JAVA基础——模板设计方法
- 查询条件清空
- uploadify 上传页面有个404请求
- ListView使用小结
- [MS SQL]SQL表达式CAST和CONVERT讲解
- hdu 1997 汉诺塔VII