Genymotion gradle 插件设备可以批量启动吗?
Can Genymotion gradle plugin devices be launched in batches?
我在 build.gradle
的 genymotion 部分定义了三个设备:
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。有没有办法做到这一点?
根据 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"
Genymotion default installation path is 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"
Start one of the virtual devices by running:
- 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>"
From: https://www.genymotion.com/#!/support?chapter=start-virtual-devices-command-prompt#faq
您可以在检查设备列表后,运行 一个特定的设备,然后通过 Gradle 插件进行测试,然后使用 adb
关机和 运行 另一个:
这里有一个 运行ning
的例子
./genyshell -c "devices list"
./genymotion/player --vm-name "Motorola Moto X - 4.4.4 - API 19 - 720x1280"
要终止模拟器使用:
pkill player
希望对您有所帮助
这可以通过为测试创建 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
我在 build.gradle
的 genymotion 部分定义了三个设备:
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。有没有办法做到这一点?
根据 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"
Genymotion default installation path is
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"
Start one of the virtual devices by running:
- 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>"
From: https://www.genymotion.com/#!/support?chapter=start-virtual-devices-command-prompt#faq
您可以在检查设备列表后,运行 一个特定的设备,然后通过 Gradle 插件进行测试,然后使用 adb
关机和 运行 另一个:
这里有一个 运行ning
的例子./genyshell -c "devices list"
./genymotion/player --vm-name "Motorola Moto X - 4.4.4 - API 19 - 720x1280"
要终止模拟器使用:
pkill player
希望对您有所帮助
这可以通过为测试创建 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