有没有办法组装androidTest版本的一种风格?

时间:2016-02-11 08:37:28

标签: android

我的Android项目中有三种口味。我如何为我的仪器测试(“androidTest”构建工件)构建其中一个?

当我使用Android Studio 2.0 Beta 2运行gradle任务assembleAndroidTest时,我得到三个输出 - 每个输出一个:

myproject-dev-debug-androidTest-unaligned.apk
myproject-itest-debug-androidTest-unaligned.apk
myproject-production-debug-androidTest-unaligned.apk

如果我只想构建其中一个怎么办?我不想等待3倍的构建时间来构建我不需要的东西(是的,这很糟糕)。

以下是包含名称“androidTest”的所有gradle任务的列表:

assembleAndroidTest - Assembles all the Test applications.
compileDebugAndroidTestSources
compileDevDebugAndroidTestSources
compileItestDebugAndroidTestSources
compileProductionDebugAndroidTestSources
compileTelenorDebugAndroidTestSources
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
installDevDebugAndroidTest - Installs the android (on device) tests for the DevDebug build.
installItestDebugAndroidTest - Installs the android (on device) tests for the ItestDebug build.
installProductionDebugAndroidTest - Installs the android (on device) tests for the ProductionDebug build.
installTelenorDebugAndroidTest - Installs the android (on device) tests for the TelenorDebug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
uninstallDevDebugAndroidTest - Uninstalls the android (on device) tests for the DevDebug build.
uninstallItestDebugAndroidTest - Uninstalls the android (on device) tests for the ItestDebug build.
uninstallProductionDebugAndroidTest - Uninstalls the android (on device) tests for the ProductionDebug build.
uninstallTelenorDebugAndroidTest - Uninstalls the android (on device) tests for the TelenorDebug build.
connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices.
connectedDebugAndroidTest - Installs and runs the tests for debug on connected devices.
connectedDevDebugAndroidTest - Installs and runs the tests for devDebug on connected devices.
connectedItestDebugAndroidTest - Installs and runs the tests for itestDebug on connected devices.
connectedProductionDebugAndroidTest - Installs and runs the tests for productionDebug on connected devices.
connectedTelenorDebugAndroidTest - Installs and runs the tests for telenorDebug on connected devices.
deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.
spoonDevDebugAndroidTest - Run all instrumentation tests on all connected devices for 'DevDebugAndroidTest'
spoonItestDebugAndroidTest - Run all instrumentation tests on all connected devices for 'ItestDebugAndroidTest'
spoonProductionDebugAndroidTest - Run all instrumentation tests on all connected devices for 'ProductionDebugAndroidTest'
spoonTelenorDebugAndroidTest - Run all instrumentation tests on all connected devices for 'TelenorDebugAndroidTest'
compileRetrolambdaDebugAndroidTest
compileRetrolambdaDevDebugAndroidTest
compileRetrolambdaItestDebugAndroidTest
compileRetrolambdaProductionDebugAndroidTest
compileRetrolambdaTelenorDebugAndroidTest

2 个答案:

答案 0 :(得分:9)

如果flavor =“flavor”和type =“debug”,请尝试:

./gradlew assembleFlavorDebugAndroidTest

答案 1 :(得分:0)

了解了如何对任何构建类型(不仅仅是debug)进行操作。测试仅针对单个构建类型创建,默认情况下为debug,但可以更改。在应用程序build.gradle中,您需要添加:

android { 

    testBuildType "myownbuildtype"
    ...
}

那么您应该可以进行./gradlew assembleMyflavorMyownbuildtypeAndroidTest

相关问题