A snapshot testing framework for iOS that validates UI correctness by comparing screenshots of views with reference images.
- 8.0.0
- Published at
- Oct 22, 2021
- 1,865
- Stars
- 71,727
- Download
- Synced at
- Oct 4, 2026
Latest release
8.0.0Oct 22, 2021, 03:40 AMDownloads slow? Switch the source anytime above
README
Project Overview
iOSSnapshotTestCase (formerly FBSnapshotTestCase) is a snapshot testing framework for iOS. It generates an image snapshot of a configured UIView or CALayer and compares it to a reference image stored in the repository, failing the test if they don't match. This addresses the challenge of testing UI code with traditional logic tests.
Key Features
- Snapshot Testing: Automatically captures and compares view snapshots.
- Clear Failure Feedback: Provides image diffs to visually show changes when tests fail.
- Easy Integration: Supports CocoaPods, Carthage, and Swift Package Manager.
- Automatic Naming: Automatically names reference images based on test class and selector.
Target Audience
- iOS developers
- Teams needing to ensure UI components render correctly under various conditions
- QA engineers looking to automate UI testing
Quick Start
- Add the framework to your project via CocoaPods, Carthage, or Swift Package Manager.
- Set the
FB_REFERENCE_IMAGE_DIRenvironment variable in your test scheme to point to the reference image directory. - Create a test class that subclasses
FBSnapshotTestCaseand callFBSnapshotVerifyViewin your test method. - On the first run, enable
self.recordMode = YES;in thesetUpmethod to generate reference images. - Disable record mode and run the test again for verification.
Core Advantages
- Visual Validation: Provides intuitive feedback through image diffs.
- Reduced Boilerplate: Replaces complex rectangle assertions with visual comparison.
- Strong Community: Originated from Uber and Facebook, with a solid community base.
System Requirements
- OS: iOS, macOS (for testing)
Release history
Sort