我有一个项目,我正在使用 AndroidJunitRunner
运行 android 仪器测试。
我现在正在使用 Cucumber 添加 UI 自动化测试。如何保留使用扩展 MonitoringInstrumentation
的运行程序的 Cucumber 测试和使用扩展 `AndroidJunitRunner 的运行程序的其他仪器测试?
在build.gradle
我曾经有过
testInstrumentationRunner "com.packagename.packagename2.MockedTestRunner"
现在我有:
testApplicationId "com.packagename.packagename2.test"
testInstrumentationRunner "com.packagename.packagename2.test.Instrumentation"
我是否需要创建第二个模块来运行 cucumber 测试?
最佳答案
要使用 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 文件。
关于android - 集成测试和 Cucumber 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51248487/