Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 7 UI Test Order

I have several UI tests that I can successfully individually or grouped. I ended up breaking my tests up into specific classes and running them that way. The issue I've come across is Xcode executes the UI tests in alphabetical order and not in order it is written/displayed. Any idea on how to get around that?

Thank you

like image 311
Sandmaster Avatar asked Nov 13 '15 18:11

Sandmaster


2 Answers

A good test suite shouldn't depend on being executed in a specific order. If yours does, you might have some test pollution. I would add common initialization logic (e.g. logging the user in) to the setUp() method of the relevant tests. Or create a helper method and share that between classes. That, combined with relaunching the app for every test, should make the order of your tests irrelevant.

like image 87
Joe Masilotti Avatar answered Sep 18 '22 00:09

Joe Masilotti


XC testing is incredibly buggy. Sometimes it seems like the direction of the wind or speed of the Earth's rotation will determine if you get a random failure or not. One fix I found that somewhat alleviates these frustrating issues are if you call this is your tearDown() function:

XCUIApplication().terminate()

Where XCUIApplication() is the application that you're running.

like image 32
Alex S Avatar answered Sep 21 '22 00:09

Alex S