【问题标题】:Integration test and Cucumber test集成测试和 Cucumber 测试
【发布时间】:2018-07-09 14:56:32
【问题描述】:

我有一个项目,我正在使用 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"

我需要创建第二个模块来运行黄瓜测试吗?

【问题讨论】:

标签: android cucumber instrumentation


【解决方案1】:

要使用 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'
}
  1. 通过执行来运行 Android Test Orchestrator

    ./gradlew connectedCheck

从 Android Studio 启用
Android Studio 3.0 及更高版本提供对 Android Test Orchestrator 的支持。要在 Android Studio 中启用 Android Test Orchestrator,请将Enable from Gradle 中显示的语句添加到您应用的 build.gradle 文件中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-10
    • 2020-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多