您可以在不同的构建变体上进行测试,但只能在一个上进行。默认为debug。
查看此链接:https://developer.android.com/studio/build/gradle-tips#change-the-test-build-type
目前仅测试一个构建类型。默认情况下,它是debug构建类型,但可以使用以下方式重新配置:
android {
...
testBuildType "staging"
}
或者,您可以按照以下方式配置您的testBuildType,以便您可以决定从命令行运行任何androidTest构建类型,指定相应的属性。
android {
...
if (project.hasProperty('androidTestRelease')) {
testBuildType 'release'
} else if (project.hasProperty('androidTestStaging')) {
testBuildType 'staging'
} else {
testBuildType 'debug'
}
...
}
从命令行./gradlew connectedCheck -PandroidTestStaging
testBuildType
。看起来目前不支持这样做,因为Gradle总是考虑最后一个testBuildType
(无论它放在哪里)。 - JCarlosR