What is iOSSnapshotTestCase?

A “snapshot test case” takes a configured UIView or CALayer and uses the renderInContext: method to get an image snapshot of its contents. It compares this snapshot to a “reference image” stored in your source code repository and fails the test if the two images don’t match.

Features:

  • Automatically names reference images on disk according to test class and selector.
  • Prints a descriptive error message to the console on failure. (Bonus: failure message includes a one-line command to see an image diff if you have Kaleidoscope installed.)
  • Supply an optional “identifier” if you want to perform multiple snapshots in a single test method.
  • Support for CALayer via FBSnapshotVerifyLayer.
  • usesDrawViewHierarchyInRect to handle cases like UIVisualEffect, UIAppearance and Size Classes.
  • fileNameOptions to control appending the device model (iPhone, iPad, iPod Touch, etc), OS version, screen size and screen scale to the images (allowing to have multiple tests for the same «snapshot» for different OSs and devices).

Overview

  • Pricing: Free
  • Resource Link: https://github.com/uber/ios-snapshot-test-case
  • Resource Maker: Uber Open Source
  • Mobile Platform Destination: iOS Apps
  • Mobile Platform Support: Native iOS
  • Programming Languages: Objective-C
  • CocoaPods: iOSSnapshotTestCase