Home

Awesome

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

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

ExpressionDevice set descriptionSnapshot count
DeviceRack.iPhone.all.landscapeAll iPhones, in landscape orientation4
DeviceRack.iPhone.all.portrait.uniqueWidthsSet of iPhones covering all possible screen widths in portrait orientation3
DeviceRack.iPad.retina.landscapeRetina 9.7" / 7.9" iPad, landscape1

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 hello@tooploox.com or Twitter by mentioning @tooploox.