I need to have data persistence between runs of my UI tests (for an iOS app). I know this might seem an anti-pattern, but I have to work with that for reasons beyond my control.
I use XCTest / XCUITest in Xcode, to run the test on an iOS app on a
real device (not a simulator). Several devices will be used, but not
simultaneously, and should start with the state the previous one
finished on.
I have explored a few options, but none work.
Unless someone has a better idea, what is the safest, most resilient way to copy back a file from the device to the mac, at the end of each test run (regardless of success or failure)? Is there a way to intercept the calls to the square Done button?
Thanks!
I use XCTest / XCUITest in Xcode, to run the test on an iOS app on a
real device (not a simulator). Several devices will be used, but not
simultaneously, and should start with the state the previous one
finished on.
I have explored a few options, but none work.
The simplest thing for me to have would be to save the state in a file on my mac and for this file to be modified directly by the test. However, as far as I can tell, this is not possible. The test cannot access files on the mac itself during the test, but only the files on the device.
I can have a file in the test directory on my mac, copy it (via a build copy phase) to the real device. Access it from the device, modify it. And lastly, copy it back at the end of the test to the computer. I’ve managed to do all this l, except the last phase. I have looked into XCTAttachements. The problem is that some tests can be stopped manually (via the square DONE button in xcode, and in that case "tearDown" will not be called).
Unless someone has a better idea, what is the safest, most resilient way to copy back a file from the device to the mac, at the end of each test run (regardless of success or failure)? Is there a way to intercept the calls to the square Done button?
Thanks!
Code Block