[英]Can Genymotion gradle plugin devices be launched in batches?
我在我的genymotion部分定义了三种设备build.gradle
:
apply plugin: "genymotion"
genymotion {
devices {
"Google Nexus 5 - 5.1.0 - API 22 - 1080x1920" {
template String.valueOf(it)
deleteWhenFinish false
}
"Google Nexus 7 - 4.2.2 - API 17 - 800x1280" {
template String.valueOf(it)
deleteWhenFinish false
}
"Google Nexus 9 - 5.1.0 - API 22 - 2048x1536" {
template String.valueOf(it)
deleteWhenFinish false
}
}
config {
genymotionPath = "/Applications/Genymotion.app/Contents/MacOS/"
taskLaunch = "connectedCheck"
}
}
connectedCheck.dependsOn genymotionLaunch
connectedCheck.mustRunAfter genymotionLaunch
genymotionFinish.mustRunAfter connectedCheck
当我运行./gradlew connectedCheck
所有三个都启动,并且同时运行测试。 如果我想添加所有要在其上测试我的应用程序的设备,则该列表将增加到20多个我的计算机无法处理的设备。 因此,我需要一种方法来批量启动这些测试,例如3。有没有办法做到这一点?
这可以通过创建仅用于测试的productFlavors来实现:
productFlavors {
dev; // dev/smoke tests
api18; api19; api21; // all api levels tests
}
这些将产生可以单独或连续启动的单独的测试任务:
task allConnectedAndroidTests(type: GradleBuild) {
tasks = [
'connectedApi18DebugAndroidTest',
'connectedApi19DebugAndroidTest',
'connectedApi21DebugAndroidTest'
]
}
只需将一个buildFlavor分配给您的一个或多个设备:
"Google Nexus 5 - 5.1.0 - API 22 - 1080x1920" {
template String.valueOf(it)
productFlavors "api21"
}
"Google Nexus 7 - 4.2.2 - API 17 - 800x1280" {
template String.valueOf(it)
productFlavors "api18"
}
并且,当您启动分配的启动任务之一时,将仅启动分配的设备并在其上运行测试。 例如:
./gradlew allConnectedAndroidTests
...
<...>genymotionLaunchConnectedApi18DebugAndroidTest
<...>connectedApi18DebugAndroidTest
<...>genymotionFinishConnectedApi18DebugAndroidTest
...
<...>genymotionLaunchConnectedApi19DebugAndroidTest
<...>connectedApi19DebugAndroidTest
<...>genymotionFinishConnectedApi19DebugAndroidTest
...
<...>genymotionLaunchConnectedApi21DebugAndroidTest
<...>connectedApi21DebugAndroidTest
<...>genymotionFinishConnectedApi21DebugAndroidTest
...
BUILD SUCCESSFUL
该示例的完整资源: https : //github.com/tomaszrykala/Genymotion-productFlavors/blob/master/app/build.gradle
根据Genymotion
文档:
如何从命令提示符启动虚拟设备?
要从命令提示符启动虚拟设备:
通过运行以下命令检索可用虚拟设备的列表:
Windows:
<Genymotion installer path>\\genyshell -c "devices list"
Genymotion的默认安装路径为
C:\\Program Files\\Genymobile\\Genymotion.
Mac OS X:
/Applications/Genymotion.app/Contents/MacOS/genyshell -c "devices list"
- Linux:
<Genymotion installer path>/genyshell -c "devices list"
通过运行以下命令启动其中一个虚拟设备:
- Windows:
<Genymotion installer path>\\player --vm-name "<virtual device name>"
- Mac OS X:
/Applications/Genymotion.app/Contents/MacOS/player --vm-name "<virtual device name>"
- Linux:
<Genymotion installer path>/player --vm-name "<virtual device name>"
来自: https : //www.genymotion.com/#!/support?chapter=start-virtual-devices-command-prompt#faq
您可以在检查设备列表之后,运行特定的设备,然后通过Gradle插件进行测试,之后使用adb
shutdown并运行另一个设备:
这是跑步的例子
./genyshell -c "devices list"
./genymotion/player --vm-name "Motorola Moto X - 4.4.4 - API 19 - 720x1280"
要杀死模拟器,请使用:
pkill player
希望对你有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.