iOS Snapshot Test Case alternatives and similar libraries
Based on the "Other Testing" category.
Alternatively, view iOS Snapshot Test Case alternatives based on common mentions on social networks and blogs.
-
PonyDebugger
Remote network and data debugging for your native iOS app using Chrome Developer Tools -
SnapshotTesting
📸 Delightful Swift snapshot testing. -
ios-snapshot-test-case
Snapshot view unit tests for iOS -
Mockingjay
An elegant library for stubbing HTTP requests with ease in Swift -
OCMockito
Mockito for Objective-C: creation, verification and stubbing of mock objects -
Buildasaur
Automatic testing of your Pull Requests on GitHub and BitBucket using Xcode Server. Keep your team productive and safe. Get up and running in minutes. @buildasaur -
Kakapo
🐤Dynamically Mock server behaviors and responses in Swift -
NaughtyKeyboard
The Big List of Naughty Strings is a list of strings which have a high probability of causing issues when used as user-input data. This is a keyboard to help you test your app from your iOS device. -
trainer
Convert xcodebuild plist and xcresult files to JUnit reports -
Cribble
Swifty tool for visual testing iPhone and iPad apps. Every pixel counts. -
Mockingbird
Simplify software testing, by easily mocking any system using HTTP/HTTPS, allowing a team to test and develop against a service that is not complete or is unstable or just to reproduce planned/edge cases. -
MirrorDiffKit
Graduation from messy XCTAssertEqual messages. -
Mockit
A simple mocking framework for Swift, inspired by the famous http://mockito.org/ -
second_curtain
Upload failing iOS snapshot tests cases to S3 -
AcceptanceMark
Tool for generating Acceptance Tests in Xcode, inspired by Fitnesse -
MetovaTestKit
A collection of useful test helpers designed to ease the burden of writing tests for iOS applications. -
SnappyTestCase
iOS Simulator type agnostic snapshot testing, built on top of the FBSnapshotTestCase. -
XCTestExtensions
XCTestExtensions is a Swift extension that provides convenient assertions for writing Unit Test. -
TestKit
The easiest way to implement full BDD in your Swift iOS projects! Use plain English specs (Gherkin) to drive tests that include both UI automation and interacting with application data & state. -
Bugfender Live
Stream the screen of an iOS device for live debugging. -
DataFixture
Creation of data model easily, with no headache. -
Parallel iOS Tests
Run iOS tests on multiple simulators in parallel at the same time -
Fetcher
Mock paging data with a variable fetch time interval.
WorkOS - The modern identity platform for B2B SaaS
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of iOS Snapshot Test Case or a related project?
README
iOSSnapshotTestCase (previously FBSnapshotTestCase)
What it does
A "snapshot test case" takes a configured UIView
or CALayer
and uses the necessary UIKit or Core Animation methods to generate 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.
Why?
We write a lot of UI code. There are a lot of edge
cases that we want to handle correctly when you are creating UIView
instances:
- What if there is more text than can fit in the space available?
- What if an image doesn't match the size of an image view?
- What should the highlighted state look like?
It's straightforward to test logic code, but less obvious how you should test views. You can do a lot of rectangle asserts, but these are hard to understand or visualize. Looking at an image diff shows you exactly what changed and how it will look to users.
iOSSnapshotTestCase
was developed to make snapshot tests easy.
Installation
Step 1: Add iOSSnapshotTestCase to your project
CocoaPods
Add the following lines to your Podfile:
target "Tests" do
use_frameworks!
pod 'iOSSnapshotTestCase'
end
If your test target is Objective-C only use iOSSnapshotTestCase/Core
instead, which doesn't contain Swift support.
Carthage
Add the following line to your Cartfile:
github "uber/ios-snapshot-test-case" ~> 8.0.0
Swift Package Manager
Add the following line to your Package.swift
:
dependencies: [
.package(url: "https://github.com/uber/ios-snapshot-test-case.git", from: "8.0.0"),
],
...or integrate with Xcode via File -> Swift Packages -> Add Package Dependency...
using the URL of the repository. We recommend using "Up to Next Major" with the Version field, as we use Semantic Versioning and only put breaking changes in major versions.
Step 2: Setup Test Scheme
Replace "Tests" with the name of your test project.
- There are three ways of setting reference image directories, the recommended one is to define
FB_REFERENCE_IMAGE_DIR
in your scheme. This should point to the directory where you want reference images to be stored. We normally use this:
Name | Value |
---|---|
FB_REFERENCE_IMAGE_DIR |
$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages |
IMAGE_DIFF_DIR |
$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/FailureDiffs |
Define the IMAGE_DIFF_DIR
to the directory where you want to store diffs of failed snapshots. There are also three ways to set failed image diff directories.
[](FBSnapshotTestCaseDemo/Scheme_FB_REFERENCE_IMAGE_DIR.png)
Creating a snapshot test
- Subclass
FBSnapshotTestCase
instead ofXCTestCase
. - From within your test, use
FBSnapshotVerifyView
. - Run the test once with
self.recordMode = YES;
in the test's-setUp
method. (This creates the reference images on disk.) - Remove the line enabling record mode and run the test.
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
viaFBSnapshotVerifyLayer
. usesDrawViewHierarchyInRect
to handle cases likeUIVisualEffect
,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 differentOS
s and devices).
Notes
Your unit tests should be inside an "application" bundle, not a "logic/library" test bundle. (That is, it should be run within the Simulator so that it has access to UIKit.)
However, if you are writing snapshot tests inside a library/framework, you might want to keep your test bundle as a library test bundle without a Test Host.
Read more on this [here](docs/LibraryVsApplicationTestBundles.md).
Authors
iOSSnapshotTestCase
was written at Facebook by
Jonathan Dann with significant contributions by
Todd Krabach.
Today it is maintained by Uber.
License
iOSSnapshotTestCase
is MIT–licensed. See LICENSE
.
*Note that all licence references and agreements mentioned in the iOS Snapshot Test Case README section above
are relevant to that project's source code only.