Forum Xamarin Test Cloud (Read Only)

Is there a method to close an app in UITest?

Is there a method to close an app in UITest?

In my test case I want close my App.

Answers

  • I'm in need of this same scenario and I've yet to find any way of doing this short of executing:
    adb shell am force-stop

    The above doesn't work in my scenario since I need our application to cleanly close.

  • JimBennettJimBennett GBXamarin Team, Insider, University, Developer Group Leader ✭✭✭✭

    We do it using a backdoor - so expose a method on your app class with an Export attribute and Invoke it from your test:

    https://developer.xamarin.com/guides/testcloud/uitest/working-with/backdoors/

    In this we do an Environment.Exit(0) which kills the app.

    In the UI test code this will throw an exception as the HTTP server loses it's connection so just wrap the invoke in a try/catch and ignore the exception.

Sign In or Register to comment.