Key Takeaways

Find a way to render views from XCTest without using UI tests. FBSnapshotTestCase is just one of many libraries that do this. The important thing is that your tests should be able to create any view or view controller, and render it to a file.

Snapshots are good for capturing aspects of appearance that would be hard to express by checking properties. But they become tempting to overuse. Because snapshot tests are slower than normal unit tests, try to limit their use to layout. Use normal unit tests to check behavior and simple state change. For example, use a normal unit test to check whether a control is enabled by checking its isEnabled property.

Snapshot tests are useful not only to record a “known good” baseline, but to also provide quick feedback to power iterative development. You can make a change, run the test, and see how the view looks—without firing up the app and navigating to that screen.