[英]Can Genymotion gradle plugin devices be launched in batches?
I have three devices defined in the genymotion section of my build.gradle
: 我在我的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
When I run ./gradlew connectedCheck
all three are launched and tests ran on them simultaneously. 当我运行
./gradlew connectedCheck
所有三个都启动,并且同时运行测试。 If I wanted to add all devices that I'd like to test my app on, that list would grow to 20+ devices which my machine would not cope with. 如果我想添加所有要在其上测试我的应用程序的设备,则该列表将增加到20多个我的计算机无法处理的设备。 Therefore, I need a way to launch these tests in batches, of say 3. Is there a way to do this?
因此,我需要一种方法来批量启动这些测试,例如3。有没有办法做到这一点?
This can be achieved by creating productFlavors just for tests: 这可以通过创建仅用于测试的productFlavors来实现:
productFlavors {
dev; // dev/smoke tests
api18; api19; api21; // all api levels tests
}
These will produce separate test tasks that can be launched separately or in succession: 这些将产生可以单独或连续启动的单独的测试任务:
task allConnectedAndroidTests(type: GradleBuild) {
tasks = [
'connectedApi18DebugAndroidTest',
'connectedApi19DebugAndroidTest',
'connectedApi21DebugAndroidTest'
]
}
Simply assign a buildFlavor to your one, or more devices: 只需将一个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"
}
And when you launch one of the assigned launch tasks, only the assigned devices will be launched and have the tests ran on them. 并且,当您启动分配的启动任务之一时,将仅启动分配的设备并在其上运行测试。 For example:
例如:
./gradlew allConnectedAndroidTests
...
<...>genymotionLaunchConnectedApi18DebugAndroidTest
<...>connectedApi18DebugAndroidTest
<...>genymotionFinishConnectedApi18DebugAndroidTest
...
<...>genymotionLaunchConnectedApi19DebugAndroidTest
<...>connectedApi19DebugAndroidTest
<...>genymotionFinishConnectedApi19DebugAndroidTest
...
<...>genymotionLaunchConnectedApi21DebugAndroidTest
<...>connectedApi21DebugAndroidTest
<...>genymotionFinishConnectedApi21DebugAndroidTest
...
BUILD SUCCESSFUL
Full source of this example: https://github.com/tomaszrykala/Genymotion-productFlavors/blob/master/app/build.gradle 该示例的完整资源: https : //github.com/tomaszrykala/Genymotion-productFlavors/blob/master/app/build.gradle
According to Genymotion
documentation: 根据
Genymotion
文档:
How do I start a virtual device from a command prompt?
如何从命令提示符启动虚拟设备?
To start a virtual device from a command prompt:
要从命令提示符启动虚拟设备:
Retrieve the list of available virtual devices by running:
通过运行以下命令检索可用虚拟设备的列表:
Windows:
<Genymotion installer path>\\genyshell -c "devices list"
Windows:
<Genymotion installer path>\\genyshell -c "devices list"
Genymotion default installation path is
C:\\Program Files\\Genymobile\\Genymotion.
Genymotion的默认安装路径为
C:\\Program Files\\Genymobile\\Genymotion.
Mac OS X:
/Applications/Genymotion.app/Contents/MacOS/genyshell -c "devices list"
Mac OS X:
/Applications/Genymotion.app/Contents/MacOS/genyshell -c "devices list"
- Linux:
<Genymotion installer path>/genyshell -c "devices list"
Linux:
<Genymotion installer path>/genyshell -c "devices list"
Start one of the virtual devices by running:
通过运行以下命令启动其中一个虚拟设备:
- Windows:
<Genymotion installer path>\\player --vm-name "<virtual device name>"
Windows:
<Genymotion installer path>\\player --vm-name "<virtual device name>"
- Mac OS X:
/Applications/Genymotion.app/Contents/MacOS/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>"
Linux:
<Genymotion installer path>/player --vm-name "<virtual device name>"
From: https://www.genymotion.com/#!/support?chapter=start-virtual-devices-command-prompt#faq
来自: https : //www.genymotion.com/#!/support?chapter=start-virtual-devices-command-prompt#faq
You can after checking list of devices, run a specific one, then test by Gradle plugin, after that using adb
shutdown and run another: 您可以在检查设备列表之后,运行特定的设备,然后通过Gradle插件进行测试,之后使用
adb
shutdown并运行另一个设备:
Here's an example of running 这是跑步的例子
./genyshell -c "devices list"
./genymotion/player --vm-name "Motorola Moto X - 4.4.4 - API 19 - 720x1280"
To kill emulator use: 要杀死模拟器,请使用:
pkill player
Hope it help 希望对你有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.