0

I'm working on app testing automation with combining both Espresso and UiAutomator.

Some of the feature are hidden behind the feature flag that is updated upon signing in. After the app gets initial bundle of data from the server the feature flag is turned on and I gotta kill the app and restart it.

I've tried with this:

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

but the app is still found in recent apps, the app is still found in recent apps I've also tried adding UiAutomator's:

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

But it still behaves as not being closed.

When I do it manually:

  1. Sign in
  2. Recent apps
  3. Swipe up then it works as expected.
  • Do you actually have to kill your whole app though? Launching your root Activity with the appropriate flags (see https://stackoverflow.com/questions/5979171/clear-all-activities-in-a-task) will "restart" your app after the user signs in without having to manually kill it and will be easier to test. – dominicoder Dec 10 '22 at 22:10
  • Yep, it is a known QA build issue - feature flagging just works fine on release build variant and it was fine with everyone until we've started to move to native testing frameworks (Espresso) from Appium. Intents flagging is there but same thing. Eventually, it will be fixed but no one knows when this "eventually" happens. – Eddie_D Dec 11 '22 at 21:29

1 Answers1

0

Just use ActivityScenario's recreate method

Link to the ActivityScenario documentation

robigroza
  • 559
  • 1
  • 5
  • 22