Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 421
Test123 Avatar asked Oct 05 '22 17:10

Test123


People also ask

How do I connect two devices to Appium?

Launch Appium server for each device and then connect to the Appium server from client with http://<HOST_IP>:<APPIUM_PORT>/wd/hub. When working with single host the HOST_IP address is localhost or 127.0. 0.1. In multi-machine setup it is something like 192.168.

Can we use single test script for testing both Android and iOS native applications?

However, it may be different from executing test scripts on Android and iOS devices because element locators may differ on Android and iOS devices. But a script written for any android or iOS device can be run on all devices with the same OS by changing desired capabilities.

How do I run the same script in multiple devices using Appium?

Simply right-click on your project, select 'New' and then 'Other'. Click “Cloud Parallel execution”. Then click “Next” and select the devices in which you want to execute your tests on. All Android or iOS devices available will be listed and can be selected.

Where can we execute Robotium test cases?

Robotium Test cases can be executed on Android Emulator as well as the Real device, we don't need to write any specific configuration code to run Robotium test cases on the Real device. Robotium Can be easily written in the Maven project also, and it can be run through continuous integration tools.


1 Answers

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.

like image 118
Paul Harris Avatar answered Oct 10 '22 02:10

Paul Harris