Playbook Documentation Beta

Class Playbook

open class Playbook

The central scenario manager.

You can use the singleton default or use it with instantiate arbitrarily.

struct Content: View {
    var body: some View {
        Text("Playbook")
    }
}

Playbook.default.addScenarios(of: "Components") {
    Scenario("Content", layout: .compressed) {
        Content()
    }
}

Initializers

init()

public init()

Initialize a new Playbook.

Properties

`default`

let `default`

The default shared instance of Playbook.

stores

var stores: [ScenarioStore]

A set of stores that holds the added scenarios.

Methods

scenarios(of:​)

public func scenarios(of kind: ScenarioKind) -> ScenarioStore

Returns a store identified by specified kind.

If there is no store yet, add and return it.

Parameters

kind Scenario​Kind

A unique identifier that stores a set of scenarios.

Returns

A store identified by specified kind.

add(_:​)

@discardableResult public func add<Provider: ScenarioProvider>(_ provider: Provider.Type) -> Self

Adds a set scenarios defined in specified provider.

Parameters

provider Provider.​Type

A type of provider that provides a set of scenarios.

Returns

A instance of self.

add​Scenarios(of:​_:​)

@discardableResult public func addScenarios<S: ScenariosBuildable>(of kind: ScenarioKind, _ scenarios: () -> S) -> Self

Adds a set of scenarios passed by function builder.

Parameters

kind Scenario​Kind

A unique identifier that stores a set of scenarios.

scenarios () -> S

A function builder that create a set of scenarios.

Returns

A instance of self.

run(_:​_:​)

public func run(_ test: TestTool, _ tests: TestTool) throws

Serialy runs specified tests conform to TestTool protocol.

Parameters

test Test​Tool

The first test to be run.

tests Test​Tool

The trailing tests to be run in order.