xcode 如何让 XCTest 以特定顺序运行测试?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23838919/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:57:18  来源:igfitidea点击:

How can I get XCTest to run tests in a particular order?

xcodexctest

提问by Bruce1q

I'm just starting to use Apple's new Xcode 5 unit testing framework. I have low-level classes that I would like to test before testing higher level classes that utilize these low-level classes. For instance I have to database control classes that use a special UUID class. It makes no sense to test the DB classes if I have a regression in the UUID system. I would like to run the suite of UUID tests first.

我刚刚开始使用 Apple 的新 Xcode 5 单元测试框架。在测试使用这些低级类的高级类之前,我想测试一些低级类。例如,我必须对使用特殊 UUID 类的数据库控制类。如果我在 UUID 系统中有回归,则测试 DB 类是没有意义的。我想先运行 UUID 测试套件。

Has anyone found a technique or practice with the XCTest framework to allow this?

有没有人找到 XCTest 框架的技术或实践来允许这样做?

回答by Joe

I have tried with success to name the test methods using a numeric scheme, like:

我已成功尝试使用数字方案命名测试方法,例如:

  • -(void)test_1_myFirstTest
  • -(void)test_2_mySecondTest
  • ...
  • -(void)test_n_myNthTest
  • -(void)test_1_myFirstTest
  • -(void)test_2_mySecondTest
  • ...
  • -(void)test_n_myNthTest

It seems it works in the desired order, however it is maybe not guaranteed.

它似乎以所需的顺序工作,但可能无法保证。

Hope this helps.

希望这可以帮助。