如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

更多相关文章

  1. V8 android 测试
  2. android FileNotFoundException错误:创建文件失败 No such file o
  3. Android左右声道音频文件测试
  4. Android(安卓)单元测试
  5. Android自动化测试MonkeyRunner
  6. 摘抄代码没测试 发起程序的返回顺序以及恩enter建取消输入法
  7. 【Appium + Python3】之安卓8.1,使用xpath定位不到元素
  8. Android之SQLite——update基于A表更新B表中的值
  9. android支付宝问题2013-07-17

随机推荐

  1. Ubuntu Lucid(10.04)上安装Google Androi
  2. EXOPlayer居中播放,类似ImageView的CENTER
  3. Android简明开发教程十六:Button 画刷示例
  4. android 保持屏幕长亮及解锁的方法
  5. Android中使用Intent打开本地图库
  6. test
  7. android按钮main.xm_基础篇
  8. Android(安卓)Drawable、Bitmap、byte[]
  9. CollapsingToolbarLayout标准使用方式
  10. Android和IOS录制mp3语音文件的方法