Java Robotium Android - 在两个不同的设备上同时运行相同的测试

Tes*_*123 5 android adb robotium

我想同时在两台设备上运行Android Robotium测试.我现在找不到任何解决方案......

更确切地说,我有一个application-test.apk,它包含多个检测类.我想运行相同的测试apk,但两个设备上的测试类不同.我知道我只能在串行模式下使用adb运行测试.

Pau*_*ris 4

您可以使用 -s 标志将 adb 命令指向特定设备。这意味着您只需打开两个终端并使用 -s 标志运行两个不同的命令,它们就会并行运行。显然,将其更改为脚本以使其成为更具可扩展性的解决方案是很容易的。

举例时间...

您有两台设备连接到您的机器,并且您想要在运行时运行两个不同的测试类(每个测试类一个):

adb devices
Run Code Online (Sandbox Code Playgroud)

你看

List of devices attached 
SERIALOFDEVICE1    device1
SERIALOFDEVICE2    device2
Run Code Online (Sandbox Code Playgroud)

然后使用显示的序列号,您可以运行命令:

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
Run Code Online (Sandbox Code Playgroud)

在哪里

com.android.foo.FooTest1
com.android.foo.FooTest2
Run Code Online (Sandbox Code Playgroud)

是您想要在每个设备上运行的类。