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

我是研究僧i 提交于 2019-12-09 13:05:34

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/13803435/java-robotium-android-run-same-test-simultaneosly-on-two-different-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!