我正在尝试执行测试套件,但我需要进行研究,以便在每次测试之前将应用程序置于清除状态。使用Gradle的connectedCheck应用程序会在每次测试之前恢复运行,我已经使用Orchestrator将clear参数设置为true,以便在测试之后擦除数据,但是如果我确实同时执行了所有测试包,则表明两次执行之间并没有真正清除该应用程序。

您对我为什么可以在android studio或命令行上完成此操作有任何建议吗?

我也尝试通过以下方式解决问题


实施ClearData批注(无效)
实施clearData任务,该任务仅在第一次测试后执行


更新
显然,我发现了
 testInstrumentationRunnerArguments clearPackageData: 'true',我已将业务流程协调器版本从1.0.1更新为1.0.2,现在可以使用了,在每次测试运行前清除了应用程序数据。

最佳答案

我设法通过更新Orchestrator版本来解决我的问题,如下所示:

build.gradle

defaultConfig {
    ...
    testInstrumentationRunner = 'android.support.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 'ANDROID_TEST_ORCHESTRATOR'
}
  dependencies {
    androidTestUtil 'com.android.support.test:orchestrator:1.0.2'

}


问题是以前的Orchestrator版本为1.0.1,不确定原因。

07-25 23:56
查看更多