Playbook Documentation Beta

Structure Snapshot

public struct Snapshot: TestTool 

The testing tool which generates snapshot images from scenarios managed by Playbook.

Snapshot Snapshot TestTool TestTool Snapshot->TestTool

Conforms To

TestTool

Represents a tool for testing scenarios managed by playbooks.

Initializers

init(directory:​clean:​format:​timeout:​scale:​key​Window:​devices:​view​Preprocessor:​)

public init(
        directory: URL,
        clean: Bool = false,
        format: SnapshotSupport.ImageFormat,
        timeout: TimeInterval = 600,
        scale: CGFloat = UIScreen.main.scale,
        keyWindow: UIWindow? = nil,
        devices: [SnapshotDevice],
        viewPreprocessor: ((UIView) -> UIView)? = nil
    ) 

Creates a new snapshot tool for export all image files into specified directory.

Parameters

directory URL

A base directory for exporting snapshot image files.

clean Bool

Specifies whether to clean directory before generating snapshots.

format Snapshot​Support.​Image​Format

An image file format of exported data.

timeout Time​Interval

A timeout interval until the finish snapshot of all scenarios.

scale CGFloat

A rendering scale of the snapshot image.

key​Window UIWindow?

The key window of the application.

devices [Snapshot​Device]

A set of snapshot environment simulating devices.

view​Preprocessor ((UIView) -> UIView)?

A closure to preprocess scenario UIView before generating snapshot.

Properties

directory

public var directory: URL

A base directory for exporting snapshot image files.

clean

public var clean: Bool

Specifies whether that to clean directory before generating snapshots.

format

public var format: SnapshotSupport.ImageFormat

An image file format of exported data.

timeout

public var timeout: TimeInterval

A timeout interval until the finish snapshot of all scenarios.

scale

public var scale: CGFloat

A rendering scale of the snapshot image.

key​Window

public weak var keyWindow: UIWindow?

The key window of the application.

devices

public var devices: [SnapshotDevice]

A set of snapshot environment simulating devices.

view​Preprocessor

public var viewPreprocessor: ((UIView) -> UIView)?

A closure to preprocess scenario UIView before generating snapshot.

Methods

run(with:​)

public func run(with playbook: Playbook) throws 

Generates snapshot images for passed Playbook instance.

Parameters

playbook Playbook

A Playbook instance to be tested.