UI Test specific view controllers outside the app

Hi,

I have a couple of very complicated view controllers that I want to be able to test thoroughly and ideally I would start the specific view controller and give it some initial conditions, interact with the UI, and then check the results.

I can't really do this sort of testing in the main app as that gets all of its data from a server and I don't want to involve the server for these tests. I just want to make sure the UI is modifying the data properly. These particular View Controllers have had the most bug regressions and so I wanted to test every aspect of them with a heap of UI tests.

Even if I were to run this as UI test, it's still not enough. I want to make sure the view controller is modifying the data correctly so I need access to the underlying model data which you can't access in a UI Test. I want to click around in the UI, and then check that data looks right.

If it was a standard non-UI test then it could have access to the data model which would be great.


Is there a way to have a hybrid testing solution where I run these as standard non UI tests but have access to all the XCUIApplication goodness? I have tried but if you call XCUIApplication inside a normal test it crashes saying that there is not target application. If you try to initialise it with a bundleID, it takes a very long time (several minutes) and ends up failing anyway.


Is this just not possible?


I have a ugly solution that I'm working through at the moment where I modify my AppDelegate to load up a completely different testing UI if launched from a UI Test. The UI is a basic UITableViewController with all of my tests listed, and I go through them one at a time. This is very ugly and it pains me to modify my normal code to handle UI Testing but I can't see an alternative. It also means that I now have to have my testing code in multiple places - one is the new table view controller that initialises the UI with specific data, and the UI Test itself.


Am I missing something?


Mof.

Post not yet marked as solved Up vote post of Moff Down vote post of Moff
1.3k views