iOS Simulator type agnostic snapshot testing, built on top of the FBSnapshotTestCase.

Overview

Tooploox

SnappyTestCase

iOS Simulator type agnostic snapshot testing, built on top of the FBSnapshotTestCase.

Why?

Snapshot testing helps to deliver views that scale correctly with a wide range of screen sizes. When it comes to view controllers, we usually want to ensure they keep visual quality on a various set of existing devices, in each supported orientation. Test suite could be run on numerous variants of iOS Simulators. However, this could be a really time-consuming task, for sure not acceptable during a development process. SnappyTestCase tackles this issue by combining test with a set of device definitions (each one including screen size, scale, and orientation) to validate with, ignoring real device simulator context information.

Features

  • Simulator type insensitive snapshot testing => restart free, quick various device testing
  • Handy definitions of iOS devices to test with - both iPhone and iPad, with chainable filtering API
  • Forcing simulator to adopt scale and orientation according to test device definition
  • Adding device type and orientation to reference file names
  • You can resize one and validate snapshot of another view (for example, you can resize whole window with UITabBarController and validate snapshot of its tab bar only)
  • Optional closure executed just before verifying view

Getting Started

Validating view controller on all existing iPhones, with portrait orientation (default):

func testAllDevices() {
    let window = UIWindow()
    window.makeKeyAndVisible()
    window.rootViewController = ExampleViewController(nibName: nil, bundle: nil)
    
    verifyViewSnaps(DeviceRack.iPhone.all, view: window)
}

For more examples of usage check out SnappyDemo project.

Defining device set cheat sheet

Expression Device set description Snapshot count
DeviceRack.iPhone.all.landscape All iPhones, in landscape orientation 4
DeviceRack.iPhone.all.portrait.uniqueWidths Set of iPhones covering all possible screen widths in portrait orientation 3
DeviceRack.iPad.retina.landscape Retina 9.7" / 7.9" iPad, landscape 1

Installation using CocoaPods

Add following line to your test target pods list in Podfile:

pod 'SnappyTestCase'

License

SnappyTestCase is distributed under the Apache 2.0 license.

Feedback

We love receiving feedback and we encourage you to contact us and share your thoughts either via e-mail [email protected] or Twitter by mentioning @tooploox.

You might also like...
Remote configuration and A/B Testing framework for iOS

MSActiveConfig v1.0.1 Remote configuration and A/B Testing framework for iOS. Documentation available online. MSActiveConfig at a glance One of the bi

AB testing framework for iOS

ABKit Split Testing for Swift. ABKit is a library for implementing a simple Split Test that: Doesn't require an HTTP client written in Pure Swift Inst

Keep It Functional - An iOS Functional Testing Framework
Keep It Functional - An iOS Functional Testing Framework

IMPORTANT! Even though KIF is used to test your UI, you need to add it to your Unit Test target, not your UI Test target. The magic of KIF is that it

An understated approach to iOS integration testing.
An understated approach to iOS integration testing.

Subliminal is a framework for writing iOS integration tests. Subliminal provides a familiar OCUnit/XCTest-like interface to Apple's UIAutomation frame

Bluepill is a reliable iOS testing tool that runs UI tests using multiple simulators on a single machine
Bluepill is a reliable iOS testing tool that runs UI tests using multiple simulators on a single machine

Bluepill is a tool to run iOS tests in parallel using multiple simulators. Motivation LinkedIn created Bluepill to run its large iOS test suite in a r

Sample project for testing out focus in SwiftUI and iOS 15

This project was to test out different ways of enabling focus in a SwiftUI app.

A flexible mock server for automated and regression testing of iOS, Android and other apps.
A flexible mock server for automated and regression testing of iOS, Android and other apps.

Note: This document is intended as a quick introduction to Voodoo. As Voodoo has a large number of features, please refer to Voodoo's Github Wiki for

Network testing for Swift

DVR DVR is a simple Swift framework for making fake NSURLSession requests for iOS, watchOS, and OS X based on VCR. Easy dependency injection is the ma

The Swift (and Objective-C) testing framework.
The Swift (and Objective-C) testing framework.

Quick is a behavior-driven development framework for Swift and Objective-C. Inspired by RSpec, Specta, and Ginkgo. // Swift import Quick import Nimbl

Comments
  • unrecognized selector sent to instance

    unrecognized selector sent to instance

    My test contains

    verifyViewSnaps(DeviceRack.iPhone.all, view: UIApplication.shared.keyWindow!)
    

    But it crashes at SnappyTestCase.swift#32 with snapshotVerifyViewOrLayer:identifier:suffixes:tolerance:]: unrecognized selector sent to instance

    iOSSnapshotTestCase 5.0.2 and SnappyTestCase 0.1.0 - am I missing something?

    opened by haemi 1
  • Size Class Agnosticism

    Size Class Agnosticism

    SnappyTestCase can simulate the different frames for each device, but it can't simulate the different size classes for each device. This means that apps that use size classes can't use this library in the way that is intended.

    Are there are any possible remedies that exist?

    opened by TekEffekt 5
Releases(0.1.0)
Owner
Tooploox
We are experts in developing data science solutions, engineering web & mobile apps, as well as designing stunning products.
Tooploox
📸 Delightful Swift snapshot testing.

?? SnapshotTesting Delightful Swift snapshot testing. Usage Once installed, no additional configuration is required. You can import the SnapshotTestin

Point-Free 3k Jan 3, 2023
Upload failing iOS snapshot tests cases to S3

Second Curtain If you're using the cool FBSnapshotTestCase to test your iOS view logic, awesome! Even better if you have continuous integration, like

Ash Furrow 129 Sep 6, 2022
Snapshot view unit tests for iOS

iOSSnapshotTestCase (previously FBSnapshotTestCase) What it does A "snapshot test case" takes a configured UIView or CALayer and uses the necessary UI

Uber Open Source 1.7k Jan 4, 2023
SwiftCheck is a testing library that automatically generates random data for testing of program properties

SwiftCheck QuickCheck for Swift. For those already familiar with the Haskell library, check out the source. For everybody else, see the Tutorial Playg

TypeLift 1.4k Dec 21, 2022
Switchboard - easy and super light weight A/B testing for your mobile iPhone or android app. This mobile A/B testing framework allows you with minimal servers to run large amounts of mobile users.

Switchboard - easy A/B testing for your mobile app What it does Switchboard is a simple way to remote control your mobile application even after you'v

Keepsafe 287 Nov 19, 2022
Testing the UI without UI Testing, a Swift experiment.

UI tests without UI Testing experiment This repo is a small experiment to see if there's an "in-between" for testing iOS applications. More feature-le

Joe Masilotti 20 Sep 26, 2022
I built this application with unit testing and test-driven development to understand TDD theory and practice

TestDrivenDevelopment Description I built this application with unit testing and test-driven development to understand TDD theory and practice, to wri

null 1 Dec 21, 2021
Implementing and testing In-App Purchases with StoreKit2 in Xcode 13, Swift 5.5 and iOS 15.

StoreHelper Demo Implementing and testing In-App Purchases with StoreKit2 in Xcode 13, Swift 5.5, iOS 15. See also In-App Purchases with Xcode 12 and

Russell Archer 192 Dec 17, 2022
A Mac and iOS Playgrounds Unit Testing library based on Nimble.

Spry Spry is a Swift Playgrounds Unit Testing library based on Nimble. The best thing about Spry is that the API matches Nimble perfectly. Which means

Quick 327 Jul 24, 2022
Multivariate & A/B Testing for iOS and Mac

This library is no longer being maintained. You can continue to use SkyLab in your projects, but we recommend switching another solution whenever you

Mattt 792 Dec 15, 2022