有一种方法可以定义应该使用哪些测试:
android {
defaultConfig {
testInstrumentationRunnerArgument("annotation", "com.hello.RunThisTestOnly")
}
}
另一种方法是使用命令行参数:
./gradlew connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.hello.RunThisTestOnly
但是,当我尝试从另一个任务设置相同的参数并运行
connectedAndroidTest
时,将忽略该参数:task taskX {
doFirst {
android.defaultConfig.testInstrumentationRunnerArgument 'annotation', 'com.hello.RunThisTestOnly'
}
finalizedBy 'connectedAndroidTest'
}
./gradlew taskX
为什么参数被忽略?
最佳答案
似乎无法更改Android插件的配置值。更多内容:https://discuss.gradle.org/t/lifecycle-of-extension/36604/2?u=eugene
关于android - 从另一个任务设置testInstrumentationRunnerArgument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62480073/