Ordering unit test using XCTest in Xcode 6

BoilingLime picture BoilingLime · Oct 6, 2014 · Viewed 15.5k times · Source

I would like to know if there is any way to tell Xcode to run unit tests in a specified order. I mean not in a same XCTestCase class file, but between all the class file.

enter image description here

For example I want to run the SitchozrSDKSessionTest before running SitchozrSDKMessageTest.

I looked over few threads on stack or on Apple documentation and I haven't found something helpful.

Thanks for your help.

Answer

JakubKnejzlik picture JakubKnejzlik · Jan 5, 2015

It's all sorted alphabetically (classes and methods). So when You need some tests running last, just change the name of Class or Method (for (nasty) example by prefixing 'z_').

So...You have Class names:

MyAppTest1
  -testMethodA
  -testMethodB
MyAppTest2
  -testMethodC
  -testMethodD

and they run in this order. If you need to run MyAppTest1 as second, just rename so it's name is alphabetically after MyAppTest2 (z_MyAppTest1) and it will run (same for method):

MyAppTest2
  -a_testMethodD
  -testMethodC
z_MyAppTest1
  -testMethodA
  -testMethodB

Also please take the naming as example :)