简体   繁体   中英

Android Gradle task: connectedInstrumentTest for Release Build?

Is there any way to run tests against Release build type or any other custom build variant?

The default behaviour of connectedInstrumentTest task is to run tests only against the Debug build variant

Any ideas?

AFAIK connectedInstrumentTest runs against the build type specified with the testBuildType attribute. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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