Prevent iOS app from resetting on launch

I am automating an iOS app using Java + TestNG + Appium on both the Xcode simulator and real iPhone device. I can’t seem to figure out why every time the app launches it does a full reset… I need the app to open from where I left off. Right now it does a fresh launch from the log in screen + 2fac authentication, which I cannot automate. I tried using the desired capabilities “noReset” true and “fullReset” false. But it does not seem to be working… Are these deprecated? How can I go about doing this?

Code
@BeforeClass(alwaysRun=true)
public void setup() throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
url = new URL(“http://127.0.0.1:4723/wd/hub”);
caps.setCapability(“platformName”, “iOS”);
caps.setCapability(“deviceName”, “iPhone 12”);
caps.setCapability(“platformVersion”, “14.3”);
caps.setCapability(“xcodeOrgId”, teamId);
caps.setCapability(“xcodeSigningId”, “iPhone Developer”);
caps.setCapability(“updatedWDABundleId”, “io.test.WebDriverAgentRunner”);
caps.setCapability(“udid”, udidValue);
caps.setCapability(“app”, bundleID);
caps.setCapability(“fullReset”, false);
caps.setCapability(“noReset”, true);

	driver = new IOSDriver<IOSElement>(url, caps);
	//driver.launchApp();
	driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}

@Test
public void attributesPage() throws InterruptedException {
        // some tests I am leaving out
}

@AfterClass(alwaysRun=true)
public void teardown() {
	driver.quit();
}

}

Logs
[XCUITest] Determining device to run tests on: udid: ‘00008101-001978C91168001E’, real device: true

[debug] [BaseDriver] Event ‘xcodeDetailsRetrieved’ logged at 1608787477160 (21:24:37 GMT-0800 (Pacific Standard Time))

[debug] [XCUITest] App is an iOS bundle, will attempt to run as pre-existing

[debug] [BaseDriver] Event ‘appConfigured’ logged at 1608787477161 (21:24:37 GMT-0800 (Pacific Standard Time))

[debug] [BaseDriver] Event ‘resetStarted’ logged at 1608787477161 (21:24:37 GMT-0800 (Pacific Standard Time))

[debug] [XCUITest] Reset: fullReset not set. Leaving as is

[debug] [BaseDriver] Event ‘resetComplete’ logged at 1608787477161 (21:24:37 GMT-0800 (Pacific Standard Time))

[WebDriverAgent] Using WDA path: ‘/usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent’

[WebDriverAgent] Using WDA agent: ‘/usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj’

[debug] [XCUITest] Crash reports root ‘/Users/Redacted/Library/Logs/CrashReporter/MobileDevice/iPhone 12 Pro’ does not exist. Got nothing to gather.

You are telling testng to restart the driver after each test. You could replace that with @AfterSuite:

Think about when you will have 50 or 100 tests and some will start fail (which is a common case and happens often). How next test should start in such case? Prefer strategy that each case does not depent on previous.

That is a good point. Ideally it should start from home page, but I can just exit every test case technically. My issue is if the app restarts, it resets the 2fac ldap authentication which I cannot automate.

Well something resetting your app if you tried normal start of app.

Just in case all combinations again

After each test is AfterMethod :wink: