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

时间:2014-02-13 12:48:01

标签: android gradle automated-tests

有没有办法针对Release版本类型或任何其他自定义构建变体运行测试?

connectedInstrumentTest任务的默认行为是仅针对Debug构建变​​量运行测试

有什么想法吗?

1 个答案:

答案 0 :(得分:13)

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

相关问题