Unit Tests on Android

3

How to do unit testing on Android?

As far as I've researched, you can only use the framework Robotium .

Is there another way to do unit testing on Android?

    
asked by anonymous 27.04.2014 / 03:02

1 answer

10

There are several options depending on what you want to do.

You can split your tests into two types:

  • Unitary
  • Functional

And you have two options of where to run them:

  • Dalvik (Inside the device)
  • JVM (Inside your machine)

Unit tests focus on testing an isolated unit, usually a class. Functional tests, however, test several units of code and / or start or end tests of a feature.

Android comes with an extension of JUnit version 3. And you can look at the standard . These tests run within the emulator / appliance and may take a little longer to execute.

Robotim is a framework that facilitates the creation of functional tests within Dalvik.

There is also Roboletric that simulates the android environment inside the JVM and running on the desktop is much faster.

There is UIAutomator which is the standard for android for versions 4.1 and above. You can use it when you want to access various applications, for example an application that uses pictures taken by the Camera.

Another test option is Monkey that performs random events in your application, very useful for testing whether all screens are ok and stress testing in the application.

There are some other libraries but these are the best known and I believe they fit most problems to test your application.

There is a great reference article on vogella.com that covers a number of cases and when to use one or another.

    
27.04.2014 / 20:26