【问题标题】:Espresso: how to kill an app fully without test stop/crash?Espresso:如何在没有测试停止/崩溃的情况下完全终止应用程序?
【发布时间】:2022-12-11 05:07:00
【问题描述】:

我正在结合 Espresso 和 UiAutomator 进行应用程序测试自动化。

某些功能隐藏在登录时更新的功能标志后面。 在应用程序从服务器获取初始数据包后,功能标志被打开,我必须终止应用程序并重新启动它。

我试过这个:

Intents.release()
scenarioRule.scenario.close()
Intents.init()
ActivityScenario.launch<MyActivity>(intent)

but the app is still found in recent apps, 该应用程序仍然在最近的应用程序中找到 我也试过添加 UiAutomator 的:

val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
device.pressRecentApps()
device.findObject(UiSelector().descriptionContains("my app's name")).swipeUp(100)

但它仍然表现为未关闭。

当我手动执行时:

  1. 登录
  2. 最近的应用
  3. 向上滑动 然后它按预期工作。

【问题讨论】:

    标签: android-espresso


    【解决方案1】:

    只需使用 ActivityScenario 的 recreate 方法

    Link to the ActivityScenario documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-28
      • 1970-01-01
      • 2014-05-31
      • 2012-08-28
      • 1970-01-01
      • 1970-01-01
      • 2017-02-08
      • 1970-01-01
      相关资源
      最近更新 更多