Android: Robotium vs android test framework

Jim picture Jim · Nov 4, 2012 · Viewed 12.2k times · Source

Everyone using Robotium for GUI testing.

Can you tell me what Android native test framework cannot do that Robotium can do? As I know Robotium can be used as black box testing, so I do not need to know about application resources. What else?

Answer

Gennadiy Ryabkin picture Gennadiy Ryabkin · May 4, 2013

Robotium

pros:

  • support hybrid applications with webViews.
  • you can bound your test to unique IDs of tested application whenever with UIatomator to write complicated test cases will need great amount of work from you
  • in UIatomator is used UiAutomatorTestCase Instrumentation which doesn't give you possibilities to call current activity and check that loaded appropriate one, you can't call connectivity- or audio- managers for wi-fi or sound tests. In Robotium you can easily call such gems and that is greatly improve efficiency of your tests
  • Open source project, so you can modify tool to your needs

cons:

  • No possibility to tests multi-process application where android:process tag used for different activities.

example code:

Robotium API example

UIautomator

pros:

  • Test case is independent from the process at which tested application works. So it can be used in places where are used additional libraries or activity is run in other process also useful if for test needed switching between several applications.

cons:

  • Works only on Android version 4.1 or more!

  • You can't use source IDs when you get ui-object instances. That mean if an application structure changed on one layout you need to refactor your test (this problem can be solved by using tags for each ui-element)

  • You can't get current activity or Instrumentation. That mean you are limited in development of your tests and not used many of android's api methods for your tests.

  • Hard to debug, you need to have script for buiding and starting your test fast and see output

hierarchy viewer:

Tool for working with UIautomator

I think both these tools are good ones, definitely possibility to switch between applications during test is awesome. You should select tool depending from your needs. I suggest Robotium for tests where you don't need to switch between applications because it have simple methods and opportunity to use Android API for writing flexible and smart tests in short code which can cover even testing of a web page inside webview and milti-process applications are very unusual.