0

My application has deep navigational chains of 8+ screens deep (Wizard-style). When i'm editing a View Controller, and i want to make a quick visual change and re-test, As a tester, I have to go through the full flow to end up where I was before recompiling, in the same Data state. Is there a way that Xcode can somehow preserve the application state, and re-run the same view controller?

If there was an automated way to detect the last launched screen, and re-display it after the recompile, that would save a lot of developers a lot of time.

I realize something like this can be built custom. Something like: IF A Certain Debug Flag is ON: - Retrieve from NSUserDefaults the Class Name of the last controller used, and redisplay it.
The problem with this is: Data State and Navigation State will not be preserved. Also, all other object state which invokes and depends on your controller will not be included. That's why I need a more universal solution.

Abizern
  • 146,289
  • 39
  • 203
  • 257
FranticRock
  • 3,233
  • 1
  • 31
  • 56
  • Would you consider UI Testing a solution? – PaulWoodIII Feb 25 '16 at 19:16
  • Ideally i want to be able to Debug, use the Xcode UI inspector and all Xcode tools. Also i believe UI Testing tools will require a test case set up, which would have time overhead greater than that of just getting to the same data state by using the simulator manually. – FranticRock Feb 25 '16 at 19:19

2 Answers2

2

IF A Certain Debug Flag is ON: - Retrieve from NSUserDefaults the Class Name of the last controller used, and redisplay it. The problem with this is: Data State and Navigation State will not be preserved.

But this is exactly the problem that the built-in state saving and restoration mechanism is intended to solve, is it not?

https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/PreservingandRestoringState.html

matt
  • 515,959
  • 87
  • 875
  • 1,141
1

I recommend you use a User Interface target and then create an XCTestCase that works on your view controller and exercise it. Use the new record button in Xcode 7 to get you started with the test case. Familiarize yourself with some of the new queries it uses for some of the dynamic information you may be creating.

Another option would be to inject your test case's UI state into the application delegate in the setup function of an XCTestCase. Then it will need custom logic to navigate to the correct view controller. Then your test case could focus on just that ViewController once the Application delegate has navigated to it.

Of course you can use the debugger and breakpoints in the Test Case and your View Controller while UI Testing. By "scripting" this you do significantly less manual clicking on a device to test a ViewCOntroller

Also you've now got a Test! Hopefully worth something to you down the road when you change something

PaulWoodIII
  • 2,636
  • 7
  • 31
  • 35