Go to homepage

Reid Main

iOS developer

  1. Archives
  2. Tags
  3. About
  4. @reidmain
  5. Email
  6. GitHub

🔗 Point-Free's SnapshotTesting Library

Unit testing and integration testing are two of the most important aspects of developing and maintaining a mobile app in my opinion. You can have the fanciest architecture or use the most cutting edge open source libraries but if you are not properly testing what you are building things will quickly come apart at the seams. I find that testing usually drives your architecture and what libraries you use because if you cannot test something easily you no longer want to use it.

For iOS one of the most important aspects of integration testing is verifying that your UI does not change unexpectedly. Not only do we want to ensure our code does not have unintended side-effects but we are also at Apple and UIKit's mercy so we need tests to ensure things don't change whenever iOS is updated. The most common way to do this is with iOSSnapshotTestCase and it does that job very well. I was part of the team at Uber that pushed the adoption of snapshot testing and was easily responsible for thousands of snapshot tests being added. But iOSSnapshotTestCase was designed many years ago with Objective-C in mind. Now that Swift has gone maintream there are many ways it could be improved.

Point-Free's SnapshotTesting library is one of the first serious attempts at rethinking snapshot testing for Swift that I have seen. I don't agree with all of their decisions (I feel they are bleeding a bit too much into unit testing territory) but I am very impressed with the API they have constructed. Some tests are almost always universally better than no tests so if you have never heard of snapshot testing do yourself a favor and check this GitHub repository out.


🎮