要使用Gradle命令行工具启用Android Test Orchestrator,请完成以下步骤:
android {
defaultConfig {
...
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// The following argument makes the Android Test Orchestrator run its
// "pm clear" command after each test invocation. This command ensures
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'
}
testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
}
}
dependencies {
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestUtil 'androidx.test:orchestrator:1.1.0'
}
>执行以下命令运行Android Test Orchestrator
./gradlew connectedCheck
从Android Studio启用
Android Studio 3.0及更高版本支持Android Test Orchestrator.要在Android Studio中启用Android Test Orchestrator,请将Enable from Gradle中显示的语句添加到应用程序的build.gradle文件中.