Android Testing Fundamentals 2, robotium, uiautomator, monkeyrunner and monkey

如Robotium官方wiki所说, Robotium是一个开源自动测试框架, 它使得黑盒(和白盒)的UI测试变得很easy。 Robotium is an Android test automation framework that has full support for native and hybrid applications. Robotium makes it easy to write powerful and robust automatic black-box UI tests for Android applications.

快速测试case:
启动xx app,进首页
选择"分类xx", 进分类页
选择"影片xx",进详情页
选择播放,进播放页
播放
向前seek
向后seek

对应脚本及使用心得:
    solo.unlockScreen();
        Thread.sleep(300);
        solo.clickOnText("分类xx");// so easy, 如果用Activity的单元测试ActivityInstrumentationTestCase2类, 会涉及大堆的findViewById的调用
        Thread.sleep(500);
        solo.clickOnText("电视剧");
        Thread.sleep(500);
        solo.clickOnText("影片xx");
        Thread.sleep(500);
        solo.clickOnText("播放");
        Thread.sleep(500);
        solo.drag(300, 1000, 660, 660, 30);// seek bar, positon is got by eclipse dump view
        Thread.sleep(10000);
        solo.clickLongOnScreen(100, 100);// to prevent the seekbar hide
        solo.drag(1000, 500, 660, 660, 30);


Ref and demo see: 
http://code.google.com/p/robotium/
http://blog.51cto.com/zt/301


VS


Android UI test framework (http://developer.android.com/tools/testing/testing_ui.html)
The Android SDK provides the following tools to support automated, functional UI testing on your application:
    uiautomatorviewer - A GUI tool to scan and analyze the UI components of an Android application.
    uiautomator - A Java library containing APIs to create customized functional UI tests, and an execution engine to automate and run the tests.
    Android SDK Platform, API 16 or higher
(Seem to be powerful, TODO to try...)


VS


Monkey and monkeyrunner (http://developer.android.com/tools/help/monkeyrunner_concepts.html, http://developer.android.com/tools/help/monkey.html)
"monkey", is a command-line tool that sends pseudo-random streams of keystrokes, touches, and gestures to a device.
The monkeyrunner tool is an API and execution environment for test programs written in Python.



Summary:
Robotium, test one apk, need resign apk;
uiautomator, requires API 16 or higher;
Monkey, just pseudo-random streams of events;
monkeyrunner, seems to be powerful;



More reading,
http://my.oschina.net/u/435726/blog/201076
http://itindex.net/detail/50270-android-uiautomator-%E8%87%AA%E5%8A%A8%E5%8C%96
http://fengbohaishang.blog.51cto.com/5106297/962705
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值