Unit tests on Android

Asked

Viewed 1,064 times

4

How to test unit on Android?

How far I searched is only possible to use the framework Robotium.

There is another way to test unit on Android?

1 answer

10


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

You can divide your tests into two types:

  • Unitary
  • Functional

And you have two options of where to run them:

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

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

The Android comes with an extension of JUnit version 3. And you can look at the standard documentation here. These tests run inside the emulator/device and may take a little longer to run.

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

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

There is the UIAutomator which is android standard for versions 4.1 and higher. You can use it when you want to access several applications for example an application that uses photos taken by camera.

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

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

There is a great reference article on the site vogella with. which covers several cases and when using one or the other.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.