簡體   English   中英

Genymotion gradle插件設備可以批量啟動嗎?

[英]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文檔:

如何從命令提示符啟動虛擬設備?

要從命令提示符啟動虛擬設備:

  1. 通過運行以下命令檢索可用虛擬設備的列表:

    • 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"
  2. 通過運行以下命令啟動其中一個虛擬設備:

    • 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM