Ordering unit test using XCTest in Xcode 6

后端 未结 7 1468
眼角桃花
眼角桃花 2020-12-24 12:37

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.

7条回答
  •  别那么骄傲
    2020-12-24 13:20

    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 :)

提交回复
热议问题