我在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.有没有办法做到这一点?
答案 0 :(得分:1)
这可以通过仅为测试创建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
答案 1 :(得分:0)
根据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
关闭并运行另一个:
这是一个运行
的例子./genyshell -c "devices list"
./genymotion/player --vm-name "Motorola Moto X - 4.4.4 - API 19 - 720x1280"
要杀死模拟器使用:
pkill player
希望有所帮助