I have a VoIP application that somewhere during the on boarding process resets itself. Because of this the first time I run the UI test it will always fail and the second time it will always pass.
I use this UI Test to create screenshots with snapshot (fastlane) and of course I can tell snapshot to try at least twice. But I also want to run this UI test whenever somebody merges to develop so I know it's broken, instead of fixing the scripts manually when we want to release. So I really would like some kind of way to let this test pass from a clean Simulator.
Is there any way possible?
I finally figured out a way to more or less get around this problem. The problem had to with the state of the application. You cannot influence the application directly from the UI test but you can set some variables.
XCUIApplication *app = [[XCUIApplication alloc] init];
[Snapshot setupSnapshot:app];
app.launchEnvironment = @{ SkipOnboarding: @YES };
[app launch];
NSDictionary *environment = NSProcessInfo.processInfo.environment;
if (environment[SkipOnboarding]) {
[SnapShotHelper skipOnboardingAndLogin];
}
SkipOnboarding
is a const I created myself. It's really just a string.
The snapshot helper sets some defaults needed to app the boot like the user was already logged in. Of course there are some caveats:
But since we're not snapshotting the login procedure it's fine. Alternatively we could create two separate UI tests if that was needed.