Search code examples
androidadbrobotium

Java Robotium Android - Run same test simultaneosly on two different devices


I want to run an Android Robotium test on two devices simultaneosly. I couldn't find any solution by now...

To be more precise, I have an application-test.apk wich contains multiple instrumentation classes. I want to run the same test apk, but different test classes on both devices. I know that I can run the tests only in serial mode, with adb.


Solution

  • You can use the -s flag to point an adb command to a specific device. This means that you can just open up two terminals and using the -s flag run both different commands and they will both run in parallel. It is obviously then easy to change this into a script to make it a more scaleable solution.

    Example time...

    You have two devices connected to your machine and two different test classes you want to run (one on each) on running:

    adb devices
    

    you see

    List of devices attached 
    SERIALOFDEVICE1    device1
    SERIALOFDEVICE2    device2
    

    then using the serials shown you can then run a command:

    adb -s SERIALOFDEVICE1 shell am instrument -w -e class com.android.foo.FooTest1 com.android.foo/android.test.InstrumentationTestRunner
    
    adb -s SERIALOFDEVICE2 shell am instrument -w -e class com.android.foo.FooTest2 com.android.foo/android.test.InstrumentationTestRunner
    

    where

    com.android.foo.FooTest1
    com.android.foo.FooTest2
    

    Are the classes you want to run on each device.