How to continue testing an iOS app, using UIAutomation instrument, even after the app exits?
Asked Answered
P

3

7

I have an app. There is a button in the app, which, if clicked, exits the app. I am testing the app using UIAutomation instruments. I want to test this button. But after the app exits, the instrument stops giving an exception. What I want to do is that after the app exists, I want to reopen the app and continue with the rest of the test. Have anyone else been in the same scenario? If so, can you please share the solution, if you have found any?

Principate answered 4/5, 2012 at 18:28 Comment(2)
Just FYI - Apple does not like it when you have a button that exists the app. Are you building for the app store?Hydromechanics
Yeah, its already on the appstore. Its a messenger and there is this button that resets the app.(it deletes the log in info) As a consequence, the app exits. So technically it is not a button to exit the app.Principate
B
3

This is not possible because Instruments loses the connection with the app process once it quits.

If you are scripting UI Automation from the command line, you can run a second automation script after the first one quits the app that then checks to make sure everything is reset.

instruments \
    -D [trace document] \
    -t [instruments template] \
    /path/to/Bundle.app \
    -e UIARESULTSPATH [directory to store test output] \
    -e UIASCRIPT reset_the_app.js

instruments \
    -D [trace document] \
    -t [instruments template] \
    /path/to/Bundle.app \
    -e UIARESULTSPATH [directory to store test output] \
    -e UIASCRIPT check_that_the_app_is_reset.js

So, rather than trying to get the same instance of Instruments to relaunch and reattach to the app, just run two separate scripts, one that does your reset-and-abort, and the other that checks the resulting state of the app.

Batista answered 14/5, 2012 at 13:53 Comment(1)
Thanks for the reply. I was thinking the same that this couldn't be done using UIAutomation itself.Principate
P
0

You can Use:

UIATarget.localTarget().deactivateAppForDuration(n); 

where n is the number of seconds you want this app to restart. I hope this helps.

Parcheesi answered 12/7, 2013 at 14:32 Comment(1)
Deactivating the app is not not in any way a restart. See doc like developer.apple.com/library/ios/documentation/iPhone/Conceptual/… for more information.Nephritic
N
0

thanks for the answers, but the documentation says:

"When a user exits your app by tapping the Home button or causing some other app to come to the foreground, your app is suspended."

So its not restarting but suspended?

Nudity answered 6/11, 2013 at 10:0 Comment(1)
yes, its just suspending the app for mentioned time in seconds and its not restarting.Kaiserslautern

© 2022 - 2024 — McMap. All rights reserved.