简体   繁体   English

Android Gradle任务:版本构建的connectedInstrumentTest?

[英]Android Gradle task: connectedInstrumentTest for Release Build?

Is there any way to run tests against Release build type or any other custom build variant? 有没有办法针对Release构建类型或任何其他自定义构建变体运行测试?

The default behaviour of connectedInstrumentTest task is to run tests only against the Debug build variant connectedInstrumentTest任务的默认行为是仅针对Debug构建变​​体运行测试

Any ideas? 有任何想法吗?

AFAIK connectedInstrumentTest runs against the build type specified with the testBuildType attribute. AFAIK connectedInstrumentTest针对使用testBuildType属性指定的构建类型运行。 You could try to make this dynamic reading it from the command line arguments: 您可以尝试从命令行参数中进行动态读取:

android {
    testBuildType obtainTestBuildType()
}

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

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

    result
}

And then call it with 然后用它来调用它

./gradlew connectedInstrumentTest -PtestBuildType=release

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM