Reputation: 63
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
Upvotes: 6
Views: 3344
Reputation: 8745
I know that the answer is a bit outdated. But using TestPlans you gain some control of tests execution order along with tests to be performed during test session.
You just need to open you target's scheme and convert it to use TestPlans
this window under
Choose Product > Scheme > Convert Scheme to use Test Plans
Then you can choose your test plan and select tests to run.
Under Configuratuions
tab you can find Execution Order
setting
I know this is a not 100% what you are looking for. But at least it can give you some hooks how to name some tests to execute in some order. For example first test could be testAuth (to authenticate user) and then other tests named in alphabetic order
Upvotes: 0
Reputation: 133
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.
Upvotes: 6
Reputation: 17018
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.
Upvotes: 9