gpt4 book ai didi

android - Genymotion gradle插件设备可以批量启动吗?

转载 作者:行者123 更新时间:2023-12-03 05:14:41 31 4
gpt4 key购买 nike

我在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。有没有办法做到这一点?

最佳答案

这可以通过创建仅用于测试的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

关于android - Genymotion gradle插件设备可以批量启动吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34590017/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com