I want to run functional (UI) tests for the login procedure in my iOS app (Xcode 7.2.1).
The app's behaviour is that upon successful login, user credentials are stored in order to automatically login (without showing the login screen) in the next launches.
So I set up a sequence of UI events in the login screen to make the login test pass on the first time the app launches in the iOS Simulator. However, next times I run my tests will fail, since the login screen doesn't even show up as expected.
I see two options here, none of them seem to fit well:
- Reset iOS Simulator's content and settings with a script before each time my tests run. I tried adding a
Run Scriptphase in the test target'sBuild Phaseswith:xcrun simctl shutdown booted && xcrun simctl erase all && killall "Simulator", and it doesn't seem to work (Simulator app doesn't launch and tests get stuck). - Include in the
-(void)tearDownsome code to clear the stored user credentials. This option is not good either as not only it's run between each test method (not per test launch), but also it seems like I don't have access to theAuthManagerclass that I use to clear user's credentials.
What do you do when UI-testing login procedures like that?