The easy way to test Android applications

I’m going to guess that most of you know what instrumentation is. In the event that you don’t, instrumentation is a feature in which specific monitoring of the interactions between an application and the system is made possible. Instrumentation also makes it possible to write test cases that interact with the application. The problem with instrumentation, however, is that it is incredibly hard to write solid test cases for applications bigger than the typical “Hello World!” application. A tremendous amount of technical details must be taken into account in order to write a good test case. Often, developers quickly realize that it will take almost as long to write a comprehensive test case as it took to write the whole application. I, myself, came to recognize the very same thing when I first started looking into how to use instrumentation tests with the android application project that I’m currently working on.

I soon came to understand that I would not be able to take advantage of all the wonderful possibilities that instrumentation offers. The reason for that is quite simple; the application that we are in the process of developing is not only extensive but also complicated with multiple activities, self-defined intents, and hundreds of views that also include scrollable lists. It would not make sense for me to spend a month writing one single test case that would only take 20 seconds to test manually. That is how Robotium was born. I needed a test framework that would help me write good and powerful test cases that emulated real users. The test case should be able to do what a real user does: click on anything that is clickable, look for irregularities, automatically move from activity to activity, etc. More importantly, I should not have to spend more than 10 minutes writing a test case that involves more then one activity.

With the help of Robotium a test case spanning over multiple activities could look like this:

public void testTextIsSaved() throws Exception {
   assertTrue(solo.searchText("Edit Window"));
   solo.enterText(0, "Some text for testing purposes")
   assertTrue(solo.searchText("Changes have been made successfully"));
   assertTrue(solo.searchText("Some text for testing purposes"));

As you can see, I don’t have to specify any technical details or tell Robotium where to look for something, such as scrolling down a list when needed. It handles the above and more all on its own.

If you are interested in writing test cases of similar nature have a look at It makes writing powerful test cases a breeze.

This Post Has 26 Comments

  1. ram

    please tell me the details about how to use Robotium-solo……………
    i have download .jar file. what should i do with that??

  2. Prasanna

    Hi Renas,
    I’m trying to test a date picker scenario on a form. I have the date picker which comes up when I click a text view which has a label on it along with a hint Enter Date.

    The problem is that I’m trying to simulate this clicking of the text view and then selecting of the date from the date picker dialog. I cannot find an method call/option in Solo to get hold of the text view (ex:with id say x).
    I’ve been trying to figure it out for the past three days.
    Will you suggest me a way to go about it?.
    Sorry to have posted this question in here.


    1. Renas Reda


      You can use clickOnView() if you want to click on a view with its ID. An example is:



  3. Sakib Choudhury

    hi Renas,

    i really love your robotium, have been using it for testing purpose for the last 3 weeks. but here is a problem i am facing. is robotium able to test across various activitities? our application is quite complex and we have to test the whole application starting from one activity (as it is not possible to figure out the actions of the other activities as they depend on the first activity, which passes on bundles to them). i am testing my project where i click on a checkbox to enter data in the database and then go out of the activity, and when i go back after a particular time, the checkbox should become unchecked again. we have some information on the top of the activity which contains the checkbox, and these information are generated from the database. now whenever i try to enter the activity using robotium, the application is crashing. but if i do it manually, nothing happens. so i was wondering if robotium is capable of testing through various activities

  4. Joe Qu

    Hi Renas,

    I’m a big fan of your robotium tool, which makes my job much easier than without it.

    Right now I’m developing test cases that require multiple devices interacting with each other in a single case. But it seems robotium cannot do this now.
    So when are we expecting to see multiple-device support come online?

    Best regards,
    Joe Qu

  5. Color Pencils

    Does Robotium have Record-Play, instead of writing up the test cases? If so, could you point to the link? I couldn’t find it anywhere.


  6. Derek Lu

    Thanks for your sharing.
    Now, I am tring to test through more activities. After one activity is done, it will jump out the application, in fact, there is another activity running on the application.
    How to fix this kind of issue, we cannot see all activities continually.

  7. SK

    Hi Renas,

    I have seen your Robotium demo written for Astro app on Youtube. Same thing I tried but I failed to execute. Can you please send me the full code of that.


  8. SK

    Hi Renas,

    I have seen your Robotium demo written for Astro app on Youtube. Same thing I tried but I failed to execute. Can you please send me the full code of that.

    Thanks in advance

  9. patrick

    hi renas, how do i add the robotium jar to my android test project without using eclipse? i tried adding the following:

    put the robotium solo jar in the libs dir of my test project
    to the application node of my AndroidManifest in the test project

    the project compiles successfully (ant debug)
    when i go to install the test apk to my emulator i receive [INSTALL_FAILED_MISSING_SHARED_LIBRARY]

    what am i missing here? thanks in advance!

  10. Nithya Balachander

    Hello Renas…
    I am trying to use Robotium to test an .apk file assuming I have no access to the source code…I have multiple activities in my .apk file..
    Is there a way to call multiple activities in the same Test package file ??
    If so, How can I implement it ??

  11. Nithya Balachander

    Hello Renas…
    I am trying to use Robotium to test an .apk file assuming I have no access to the source code…I have multiple activities in my .apk file..
    Is there a way to call multiple activities in the same Test project file ??
    If so, How can I implement it ??

  12. Hi Renas….

    I am trying to use Robotium to test .apk file. How i can click image button in my .APK file????

  13. vijay

    how to read user data stored on sd card? i have istall application PRN _status on sd card and i ahve to read which data its stored on sd card is there any password stored at sd card??

  14. vijay

    how to read user data stored on sd card? i have istall application PRN _status on sd card and i have to read user data

  15. vijay

    Hi Renas,

    I have instatlled Android 4.0
    Robotium Solo 2.5 jar.
    I have created one small application from the blogs & when i try to run the application, Android Emulator is opened but, It shows the error message like

    java.lang.RuntimeException:Unable to resolve activityfor :Iintent{ act= android:intent.action.MAIN flg=0×1000000 cmp=com.calculator/.test.MyFirsrApp }
    at android.test.InstrumentationTestCase.launchActivityWithIntent(Instrumentation
    at android.test.InstrumentationTestCase.launchActivity(Instrumentation
    at android.test.InstrumentationTestCase2.getActivity(
    at android.test.AndroidTestRunner.runTest(
    at android.test.AndroidTestRunner.runTest
    at android.test.InstrumentationTestRunner.Onstart(

    When we click in the error message ,it shows that,Class File Editor
    Source not found –> msg is displayed..

    This is my issue…
    Kindly sort it out … ASAP


  16. mohan kumar

    Hey, good stuff,
    I’m working on WIFI implementation in android.
    can u tell me how to use Robotium for WifiManager class.

  17. Jeff Byer

    What is the answer to running a robotium test case on multiple devices at the same time?

  18. Sukanta

    how to pass arguments to the robotium from the command line(ubuntu terminal) to test the project as much time i want to test..means 10 times or 200 times as much time i wish..!!
    please share your experiance as soon as possible.

  19. suki


    I want to do cts test, but it’s looking very complex to me. Can any one help me out by describing the cts test from the beginning. Means after setting up android sdk and avd plugins then what we have to do for doing CTS test. Please reply soon.. :)

  20. Daniel

    Hi ,

    doas robotium support multiple activity classes ?
    within my project i have 2 classes : Run1 and Run2

    both have editText i need to test together and also separattly this 2 editText

    how do i configure the test case class


  21. Daniel

    Hi, first i want to congrats for a very good product.
    Now, I’m wondering if it supports running it independently directly from the phone when the phone is disconnected.
    I give it a try with emulator and it runs nicely, but I want to use few phones and not all of them can be connected to the pc.

  22. Dhiraj Kumar

    Hi Renas

    I want to accsess id in test project but i dont have a source code i have .apk file so how can i acesses id in test project.

  23. musica


    How to resolve below error :
    at android.test.InstrumentationTestCase.launchActivityWithIntent(
    at android.test.InstrumentationTestCase.launchActivity(
    at android.test.ActivityInstrumentationTestCase2.getActivity(
    at com.a.b.test.TestApk.setUp(
    at android.test.AndroidTestRunner.runTest(
    at android.test.AndroidTestRunner.runTest(
    at android.test.InstrumentationTestRunner.onStart(

Leave a Reply