Mobile Testing Robotium Framework - Mobile Testing

What is robotium framework?

Robotium is an open-source test framework which is used for writing automatic grey-box test cases for Android applications. Using Robotium, test case developers can write function, system and acceptance test scenarios, spanning multiple Android activities.

Robotium can be used both for testing applications where the source code is available and applications where only the APK file is available.

Advantages of Robotium

  • Easy to write, shorter code and less time needed for writing solid test cases.
  • Powerful test cases can be developed with less knowledge of the application under test.
  • Framework handles multiple Android activities automatically. Readability of test cases is greatly improved, compared to standard instrumentation tests.
  • Automatic timing and delays.
  • Automatically follows current Activity.
  • Automatically finds Views.
  • Automatically makes its own decisions (ex: When to scroll, etc.)
  • No modification to Android platform.
  • Test execution is fast.
  • Test cases are more robust due to the run-time binding to GUI components.
  • Integrates smoothly with Maven or Ant.

Disadvantages of Robotium

  • Robotium cannot handle Flash or Web components.
  • Handles only one application at a time.
  • It cannot simulate clicking on soft keyboard using Robotium (need to use ‘enterText()’ to enter text into an EditText field)
  • Robotium cannot interact with Status Bar Notifications − that is, pull down the Notification area and click on a specified Notification.
  • Can be a bit slow, especially running on older devices.

How to Use Robotium

Step 1 − Prerequisites for using Robotium is Java SDK (minimum 1.6). First, install Java on your system by following below steps.

  • Download JDK and JRE from Oracle Technology Network
  • Accept license agreement.
  • Install JDK and JRE.
  • Set environment variable as shown in the screenshot below.

environment variable

Step 2 − Download Android Studio from Android Studio

  • Double click the exe and run the installer.
  • Continue with all default options.
  • Set the ANDROID_HOME.

Step 3 − Install Android images and tools.

  • Click on SDK Manager


  • Select the necessary package. For example, if we are building an App for Android 4.4.2, then make sure the following packages are checked under the Tools section
  • Android SDK Tools rev 22.6.3
  • Android Platform-tools rev 19.0.1
  • Android SDK Build-tools rev 19.1

Step 4 − Create Android Virtual Devices.

  • Open Android Studio and click AVD Manager in the toolbar. AVDs allows to test and run our Android apps.


  • Use below settings for a Nexus5 AVD
  • Device − Nexus 5 (4.95, 1080 x 1920; xxhdpi)
  • Target − Google APIs x86 (Google Inc.) - API Level 19
  • Make sure you select the target with Google APIs in the name.
  • CPU − Intel Atom (x86)
  • Check the box for Use Host GPU
  • Click OK
  • Now check if the AVD you created in the AVD Manager, where you can start it, delete it, or create another one!

Step 5 − Robotium Jar file Download Robotium Jar file from RobotiumTech

Test an App with Robotium

To test an App with Robotium, follow the steps given below

Step 1 − Create a test Project in the Android Studio named as “RobotiumTest”.

robotium test

Choose all the default options until you reach to the main page.

Step 2 − Copy the Robotium jar file into the Lib folder of the project.

jar file

Step 3 − Add the dependency in build.gradle file under src folder.

androidTestCompile ''

Step 4 − Sync the Gradle.


Step 5 − Create the Test class as shown below

Step 6 − Save all changes and ensure there are no errors.

Step 7 − Now, run the test case. If the test case is successful, below shown output will be displayed.


All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

Mobile Testing Topics