Manage Your Snapshot Tests

To get the most out of your snapshot tests, you should know that these tests are slow, and somewhat touchy. Also, you don’t have to wait until you’ve finished coding the views for them to be useful.

Slow Snapshots: Keep Them in Their Own Corner

When you first discover snapshot tests, it’s tempting to use them to test all kinds of visible state. But compared to a normal unit test, a snapshot test is an order of magnitude slower. That is, in the time it takes to run one snapshot test, you can run ten to twenty unit tests.

The speed of one snapshot may not seem like much. But they accumulate quickly. To keep snapshot tests from slowing down rapid feedback, I keep snapshots in their own corner. Here’s how:

First, ...

Get iOS Unit Testing by Example 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.