Sharing Constants

All of the constants that you have used so far you have put into Constants.swift. It would have been technically possible to add each of these constants to the top of the test file that you used them in. However, as you have already seen, it is quite common to use the same constants in multiple tests and in multiple test files. On the one hand, if you do not put constants in the files where they are first used, they will be visible from other test files – so long as you do not mark them private. On the other hand, if you follow this approach, your shared constants will be scattered throughout your test files and harder to track down.

For this reason, stylish Swift programmers put their shared test constants into a ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.