2014-02-13 37 views

回答

10

AFAIK connectedInstrumentTest針對使用testBuildType屬性指定的構建類型運行。 你可以試着讓這個充滿活力的命令行參數讀取它:

android { 
    testBuildType obtainTestBuildType() 
} 

def obtainTestBuildType() { 
    def result = "debug"; 

    if (project.hasProperty("testBuildType")) { 
     result = project.getProperties().get("testBuildType") 
    } 

    result 
} 

然後用

./gradlew connectedInstrumentTest -PtestBuildType=release

+0

感謝調用它。這看起來很合理,但命令行變量看起來像省略了。 fyi:我正在使用buildToolsVersion「19.0.1」gradlew dist(gradle-1.10) – gemini

+0

你說得對。看起來我使用了錯誤的方法名稱,請嘗試更改它(請參閱更新後的答案)。 – rciovati

+1

偉大的只是意識到這一點。現在發生的另一個問題是...當我嘗試運行時./gradlew connectedInstrumentTest -PtestBuildType = release 無法找到工具信息:ComponentInfo {com.example.app.tests/com.example.app.tests.SpoonInstrumentationTestRunner } SpoonInstrumentationTestRunner.java位於與特定構建類型無關的默認instrumentTest目錄中 任何想法都將不勝感激? – gemini

相關問題