5 test frameworks you need to know about Android automation testing

Appium


Appium is an open source mobile testing tool that supports iOS and Android, it can be used to test any type of mobile application (native, web and hybrid). As a cross-platform tool, you can run the same tests on different platforms. To enable cross-platform functionality, Appium uses vendor-provided Android UI frameworks to implement tests: XCTest in iOS and UIAutomator or Instrumentation in Android. It encapsulates these vendor frameworks into Selenium WebDriver, which enables developers using Appium to write tests in various types of languages: Java, Objective-C, JavaScript, PHP, Ruby, Python, and more. This also makes writing Appium tests very similar to writing Selenium tests.

WebDriver was originally created for web testing, Appium extends WebDriver with additional API methods, making it more suitable for mobile automation.

Here are some useful Appium features:

  • Nothing needs to be installed on the device.
  • No need to recompile or change the application to match Appium.
  • Appium has a very large and active community.
  • Appium ships with a tool that scans and analyzes an application's UI components - Appium UI Inspector. Developers can also use Android Studio's UI Automator Viewer.
  • If you need to write tests for iOS and Android and you are a Selenium lover, Appium would be a good choice. 

Calabash


Calabash is an open source mobile testing tool developed and maintained by Xamarin Corporation, supporting native and hybrid applications on iOS and Android. Calabash tests support gesture recognition (gesture), assertions (assertions) and screenshots (screenshots) and other functions, usually integrated with the driver development testing tool Cucumber.

Xamarin announced in 2017 that it would cease development on Calabash. Given this decision, you can use Calabash as a less-than-ideal alternative testing solution.

Espresso


Espresso is an Android UI framework from Google. It is a lightweight, white-box tool for application developers, which means that to take full advantage of it, test developers must be sufficiently familiar with and use application code. Espresso's tests are very reliable and run fast, since Espresso has access to the internals of UI objects, it can be used to test WebViews, i.e. development of hybrid applications.

The downside of Espresso is that it can only test one app at a time and it doesn't have access to device resources. However, this problem can be easily solved by using joint tests created with UI Automator, and this article has a good explanation of how to implement it.

Sauce Labs supports real device testing of Espresso.

UI Automator


UI Automator is a mobile testing Android UI framework developed and maintained by Google. Its main functions include cross-application functional testing, that is, the ability to test multiple applications and switch between installed and system applications.

UI Automator is a black-box testing tool, which means that test developers do not need to know the internal application structure and can rely entirely on visible UI elements. UI Automator tests are written in Java and consist of two sets of APIs: one is UI Automator APIs, which are UI components that control the application; the other is device state APIs, which are used to access and perform operations on the device (such as changing Rotate the device, press the arrow button, press the back, Home or Menu button, etc.). It also comes with a very useful UI Automator Viewer, a graphical user interface tool that can scan and analyze the UI components currently configured on the device.

The downside of UI Automator is that it doesn't support WebViews built on top of hybrid Android apps, so UI Automator only supports native Android apps.

Robotium


Robotium是一个开源的Android UI框架,它诞生于2010年,现在已经是一个非常成熟和稳定的工具。其最近的一个版本是5.6.3,发布于2016年9月。在最新的几个版本中,其测试可读性和测试执行的速度都有了显著提高。

大多数涉及到Robotium的技术博客、教程和课程都是黑盒测试类型的。但实际上,它算是灰盒测试的,因为编写Robotium测试需要了解内部应用程序结构。

以下是Robotium的部分主要特性:

  • 支持本机和混合应用程序。
  • 可以在真实设备和模拟器上运行测试。
  • 支持完整的Android UI工具:活动、按钮、菜单、toast、对话框等。
  • 支持手势。
  • 有一些设备控制功能:改变设备方向,截屏,解锁屏幕等。
  • Robotium recorder(https://robotium.com/)是一个付费的Android Studio和Eclipse插件。这是一个很好的工具,可以快速的启动和运行测试。
  • 可以作为持续集成的一部分运行。
  • Robotium的选择语言是Java。

Robotium得到了Sauce Labs的支持,可以用于真实设备的测试。 

结语

为您的项目选择正确的Android UI框架是一项很有挑战性的工作,在某些情况下,您可能需要使用多种工具来达到正确的平衡,这就是像Sauce Labs这样的支持多种测试框架的测试网格大受欢迎的原因。

 

本文翻译自dzone.com,首发于慧都控件网

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326119342&siteId=291194637