Robotium is a “Black-Box” testing tool that simulates and automates user interaction such as clicking, touching, entering text and any other gesture which is possible on a touch device. It is a test structure which was created to ease the writing of powerful and robust automatic black-box test cases for Android applications. With its support, developers who create test cases can write system, function, and acceptance test scenarios, covering multiple Android activities. It provides full support for Activities, Dialogs and Context Menus. Robotium is an open-source tool, so it can be used by individuals as well as Enterprises. Execution of tests could either be done on a real device or on the Android simulator (AVD – Android Virtual Device). It is built on the Java and the JUnit test structure. Robotium can be used for testing the applications where the source code is available and also the applications where only the apk is available. Robotium extends the Android test framework so as to make it simpler to write tests. For testing with Robotium, the main class is Solo.
How to create a Robotium Project?
1. Before creating a Robotium Project, the prerequisites are:
a) Download and Install JAVA.
b) Download ADT bundle.
2. To create a project, first step is to Open eclipse which contains your android application that is to be tested.
3. Right click on the android project – Go to Android Tools and click on new Test project.
4. Enter the Test project name and click on Next button.
5. The Application under test is to be selected as the target.
6. After that, click on Finish button.
7. In the eclipse workspace, Test project will be created.
8. Next step is to download Robotium solo jar which provides methods to call the Android user interface.
9. After right clicking on the Test project in the workspace, go to Build path and click on Configure build path.
10. Move to libraries tab, click on “Add external jars” option.
11. Browse the Robotium jar file which was downloaded, add it to the libraries and click “OK”.
12. After following the above steps, Robotium Test project is successfully created. Now classes can be created under the project and test cases can be written accordingly.
Benefits of Robotium:
1. The code is short and easy to write.
2. Multiple Android activities can be automatically handled by it.
3. It greatly improves the readability of test cases in comparison to standard instrumentation tests.
4. It provides automatic timing and delays.
5. It automatically follows current Activity and makes decisions on its own.
6. Views can be easily found using it.
7. Execution of tests is faster and the test cases are more robust due to run-time binding.
Features of Robotium:
1. Robotium allows the users to write powerful test cases quickly with zero or minimal knowledge of the application under test.
2. APIs are offered by Robotium to directly interact with UI controls within the application.
3. Android 1.6 and above versions are supported by Robotium officially.
4. Robotium doesn’t modify the Android platform.
5. Command prompt can be used to execute the Robotium test.
6. Robotium can be added to the project's build automation process and it can be integrated smoothly with Maven or Ant.
7. Robotium can capture screenshots.
Limitations of Robotium:
1. Flash components cannot be handled by Robotium.
2. Only one application at a time can be handled by Robotium.
3. It is not able to interact with the notifications on Status Bar.
4. When run on older devices, it can be a bit slow.