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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.