如何使用Python和Monkeyrunner在AVD Android Emulator上执行并行测试

时间:2015-10-28 21:16:19

标签: android python-2.7 monkeyrunner avd parallel-testing

我正在使用AVD(Android模拟器)上的monkeyrunner执行脚本测试,顺序执行下面的代码,我想知道是否可以在所有模拟器上并行执行脚本测试。

* listADVtotest 是一个文本文件,其中包含模拟器的在线名称,我呼叫monkeyrunner执行测试的每个模拟器。

for index, line in enumerate(listAVDtotest):
     emulatorid = listdevtotest[index][0]
     deviceid = listdevtotest[index][1]
     print "Identified device %s" % deviceid
#Execute test with monkeyrunner for each AVD
     subprocess.call('monkeyrunner -v ALL Test1.py ' + emulatorid + ' ' + deviceid + ' ' + str(index), shell=True)

1 个答案:

答案 0 :(得分:1)

可以使用AndroidViewClient/culebra但不能使用monkeyrunner

culebra支持命令行选项

  -m, --multi-device               enables multi-device test generation

可以生成测试,以便在多个设备上同时运行。例如,当您生成测试并让我们说点击照片图标时,将生成以下行

[_vc.findViewWithContentDescriptionOrRaise(u'''Photos''').touch() for _vc in allVcs()]

将在所有设备上执行触摸

这篇文章(http://dtmilano.blogspot.ca/2015/05/android-culebra-multi-device.html)有一个更详细的解释,还有一个在3台设备上同时运行的计算器测试的视频。这种能力的显着之处在于,相同的测试在3种不同的设备上运行,具有不同的屏幕分辨率和不同的方向。