Skip to content

Is the ordering of it examples guarenteed? #1150

Answered by CraigSiemens
amomchilov asked this question in Q&A
Discussion options

You must be logged in to vote

I believe the execution order is fairly fairly consistent by default but it I wouldn't rely on it.

It's generally bad practice for a test to depend on the state from another test. Each test should be a single unit that can be run in insolation. It's easy to break if tests are removed or changed and Xcode allows running tests in a random order and running single tests, and Quick allows focusing on a single test.

For example if you focused the second test it would fail.

    fit("returns the cache value on the second lookup") { ... }

I'd generally add a context for each of the "things" that can happen to the object being tested with a beforeEach to do it. Then the tests in the context will g…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by younata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants