Search code examples
xcode-ui-testing

How do I keep the app open between UITests in Xcode


I have a series of UITests I want to run as individual tests but I don't want to relaunch the app between each test. How can I launch the app and keep it open so it doesn't shutdown and restart between tests.

I tried putting XCUIApplication().launch() in init() but got an error.


Solution

  • In your setUp() method, remove [[[XCUIApplication alloc] init] launch]; and put it into the first test you will be performing.

    For eg.,

    If you have tests: testUI(), testUIPart2(), testUIPart3(), etc., and it runs in this order, put [[[XCUIApplication alloc] init] launch]; into the first line of testUI() and no where else.