Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run tests sequentially in Xcode 6 beta3

From what I can see, it looks like Xcode runs tests from a given TestCase sequentially, but from different TestCases in parallel.

Is it possible to configure a project/target so that all the tests run sequentially ? For instance, this would be useful to run various integration tests that have side effects affecting the other tests. (e.g. access to same database tables)

EDIT: to clear out some confusion: I am not talking about forcing a specific sequence of tests, just about making sure that the tests do not interfere with each other.

Thanks

like image 795
Sami Dalouche Avatar asked Jul 11 '14 14:07

Sami Dalouche


People also ask

How do I run a test multiple times in Xcode?

Enable test repetition in your test plan, xcodebuild , or by running your test from the test diamond by Control-clicking and selecting Run Repeatedly to bring up the test repetition dialog.

How do I run all test cases in Xcode?

Using ⌃⌘U will run all the test cases without building the test target. It is the opposite of ⇧⌘U. This is especially useful when you want to skip a slow-building test target and jump straight into running all the test cases.

How do I run unit tests in Xcode?

Adding a unit test in Xcode Go to File > New > Target. Select iOS Unit Testing Bundle and then click Next. When you create a new Unit Test target for your project, it consists of a template class.


1 Answers

If you need your objects to have a consistent starting state for tests, I would recommend adding calls to the setUp method of your test classes. setUp called before each of the tests in a test class.

If you need your suite to run in a certain order, it sounds like you don't have unit tests and are running integration tests. You can try to use setUp to initialize your lower-level objects. If you are only interested in the behavior of a higher-level class, try mocks. The OCMock framework is available for Objective-C.

like image 182
Aaron Kapilivsky Avatar answered Sep 20 '22 21:09

Aaron Kapilivsky