介绍
Robotium是一款国外的Android自动化测试框架,主要针对Android平台的应用进行黑盒自动化测试,它提供了模拟各种手势操作(点击、长按、滑动等)、查找和断言机制的API,能够对各种控件进行操作。Robotium结合Android官方提供的测试框架达到对应用程序进行自动化的测试。另外,Robotium4.0版本已经支持对WebView的操作。Robotium对Activity,Dialog,Toast,Menu都是支持的。
优缺点
优点:
- Easy to use
- Tests are easy to read
- Doesn`t require access to source code. Can test an APK
- Can identify elements easily
- Can fall back on default Android framework
- Great support
缺点:
- Not all views and objects are currently supported (SlidingDrawer)
- Slower compared to unit testing
- Single class containing all methods, Selenium 1 style. This is going to get messy
用法
Robotium的用法很简单,同时也是很有效的黑盒测试工具。我们在使用时通过Solo对象的实例,可以创建丰富的测试用例。Solo不仅对activity支持,对Toast,Menu,Dialog也是支持的。