当前位置: 代码迷 >> Android >> Android 测试 Appium、Robotium、monkey等框架可能工具对比
  详细解决方案

Android 测试 Appium、Robotium、monkey等框架可能工具对比

热度:720   发布时间:2016-04-28 05:00:57.0
Android 测试 Appium、Robotium、monkey等框架或者工具对比

1. Appium测试 (功能测试,用户接受度测试,黑盒测试) - Rating: 8

Website: http://appium.io/

Appium测试相当于黑盒测试。只是测试UI逻辑正确性。所以Appium测试框架提供的方法有限。获取一个AppiumDriver对象。该对象只是有很多findElements()的方法,获取到UI元素。UI元素是WebElement,这个类提供的方法基本是获取信息为主,比如获取name,class,tagName,location,text,isSlected,isTouched等信息。还有一个点击事件产生函数click()。遗憾的是没有longClick()事件。整个测试框架只有这2个比较有用的对象可以操作。所以整体上看,这个这个测试框架,只是测试UI逻辑的正确性,不能升入测试业务逻辑流程。也没有办法去检测。

Pros:

  • Open Source
  • 可以使用不同语言来编写测试代码
  • 可以测试不同平台程序:Android/iOS/Web/Hybrid
  • 社区较活跃

2. Robotium测试 (功能测试,用户接受度测试,黑盒+白盒测试) - Rating: 8

Website:https://code.google.com/p/robotium/

Pros:

  • Quite popular for android testing
  • 可以对源码测试,也可以测试apk
  • 可以测试Android Native和Android Hybrid App
  • 可以测试网络链接和声音等
  • Open Source
  • 社区较活跃,资料比较好找

3. AndroidTest (单元测试,逻辑测试,白盒测试)

这个在https://developer.android.com/tools/testing/index.html SDK中有详细描述。能够针对Android各种组件进行测试,包含ActivityTest,ServiceTest,ContentProviderTest。能够获取每一个组件的 资源,并且注入代码进行测试。

1) Activity Testing 主要是测试Activity的,主要测试的方向是以下三个方向:

  • 对于Activity的生命周期的控制。
  • Dependency injection: Instrumentation allows you to create mock system objects such as Contexts or Applications and use them to run the activity under test. This helps you control the test environment and isolate it from production systems. You can also set up customized Intents and start an activity with them.(翻译不太好,大概就说依靠注入去产生模拟对象然后模拟系统环境。)
  • 控制UI的控件元素,然后产生触控事件。这个功能类似Appium描述的。

2) Service Testing 测试的是Service生命周期是否正常

3) Content Povider Testiing 因为provider是一个数据出入口,所以测试的是数据能否正常被读取出来,能否正常写入。测试这个provider提供的URI是否全部正常。测试一些非法的URI是否能够被拦截等。 总的来说Android自带的是单元测试。适合白盒测试。Android 自带的Test的话能够获取的UI界面或者什么的更多的信息,提供的测试方式也更多。

4. Monkey (压力测试)

这个是Android提供的系统工具。它向系统发送伪随机的用户事件流(如按键输入、触摸屏输入、手势输入等),实现对正在开发的应用程序进行压力测试。Monkey测试是一种为了测试软件的稳定性、健壮性的快速有效的方法。

  • 测试的对象仅为应用程序包,有一定的局限性。
  • Monky测试使用的事件流数据流是随机的,不能进行自定义。
  • 可对MonkeyTest的对象,事件数量,类型,频率等进行设置。

    在SDK 有详细描述http://developer.android.com/tools/help/monkey.html。在SDK中有测试的详细参数描述。这个只是个测试工具不涉及编码

5. monkeyRuner (功能测试,用户接受度测试,黑盒测试) - Rating:5

SDK:http://developer.android.com/tools/help/monkeyrunner_concepts.html 这个是用python编码实现的测试。主要有3个类MonkeyDevice、MonkeyImage、MonkeyRuner。最主要是通过运行程序,在程序中提供按键或触摸事件的输入数值然后截屏,通过截屏对比是否是正常的运行。事件API: press (string name, dictionary type) touch (integer x, integer y, integer type) drag (tuple start, tuple end, float duration, integer steps) startActivity (string uri, string action, string data, string mimetype, iterable categories dictionary extras, component component, flags) 等事件,详细请参考API。

6. UIAutomator - 官方 (黑盒测试,功能测试) - Rating: 7

SDK:http://developer.android.com/tools/testing/testing_ui.html

Pro:

  • 可以测试需要在不同app之间切换的情况
  • 官方支持

Cons:

  • 只能测试Android native app
  • 需要Android SDK 4.1+
  • 无法获取当前load的activity
  • 无法做网络链接测试和声音测试
  • debug过程比较麻烦

主要功能跟APPIUM类似,主要类UIDevice,UiObjec,UiSelector,UiCollection。UIdevice更Appium的AppiumDriver类比。剩下的更WebElement类比只是划分得更详细。功能上也更Appium类似。通过text,className等信息找到UI控件然后进行操作。

7. MonkeyTalk (白盒测试,功能测试)

  相关解决方案