See the Difference in a Snapshot Failure

Now we have a passing snapshot test. But what happens when the test fails? Let’s find out by changing the layout.

Open Main.storyboard and select the button. Show the Size Inspector by selecting View Inspectors Show Size Inspector from the Xcode menu or press --6. In the Constraints section, find the “Align Trailing to: Safe Area” constraint as shown here:

images/snapshot/align-trailing.png

Click Edit and change the constant to 25. Run the tests. The snapshot will report a failure. If you go to the test case, you’ll see the test failure annotation:

But there’s more information that’s not visible in the failure annotation, even ...

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.