問題描述
有沒有人知道如何將命令行參數(shù)傳遞給使用 gradle 運(yùn)行的 Android 儀器測(cè)試.使用 -p 參數(shù)或 -D 參數(shù)調(diào)用 gradle connectedInstrumentTest 似乎不起作用.我正在嘗試使用 gradle 將命令行參數(shù)傳遞給我的儀器測(cè)試.
Does anyone has an idea about how to pass command line arguments to Android instrumentation tests run using gradle. Calling gradle connectedInstrumentTest with -p arguments or -D arguments did n't seem to work .I am trying to pass command line arguments to my instrument test using gradle.
推薦答案
根據(jù)文檔從1.3.0版本的插件開始就有可能:http://tools.android.com/tech-docs/new-build-system
It is possible since 1.3.0 version of plugin according to docs: http://tools.android.com/tech-docs/new-build-system
現(xiàn)在可以在build.gradle(在 defaultConfig 或 per flavor 中):
It's now possible to specify instrumentation test runner arguments in build.gradle (in defaultConfig or per flavor):
android {
defaultConfig {
testInstrumentationRunnerArguments size: "medium"
}
}
這也可以在命令行上完成:
This can also be done on the command line:
./gradlew cC -Pandroid.testInstrumentationRunnerArguments.size=medium
./gradlew cC -Pandroid.testInstrumentationRunnerArguments.size=medium
這篇關(guān)于使用 gradle 進(jìn)行 Android 儀器測(cè)試的命令行參數(shù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!