<commit_before># Scenarios

_Human-oriented testing in Swift._

## Introduction

Scenarios is a lightweight wrapper around [Quick][] for writing acceptance tests in BDD style. It's modelled after [Cucumber][].

```swift
final class GreetingFeature: Feature {
  override func scenarios() {

    // In order to keep users coming back
    // As a developer
    // I want to greet them warmly when returning to the app

    Scenario("Greeting on launch")
      .When("the app has launched")
      .Then("the greeting 'Hello, world!' should be on screen")

    Scenario("Personalised greeting")
      .Given("the app has launched")
      .When("I enter 'Friend' as my name")
      .Then("I should see the greeting 'Hello, Friend!' on screen")

  }
}
```

[Quick]: https://github.com/Quick/Quick
[Cucumber]: http://cucumber.io/

When paired with Xcode UI Testing, Scenarios gives you a high-level, user-focused and very expressive way to describe the functionality of your app. Or you can use it to define acceptance tests for your library or framework.

Scenarios isn't a UI testing tool. It's a tool for _organising thought_.

## Getting Started

#### Install

You can install Scenarios as a dynamic framework via [Carthage][]. Just add this to your `Cartfile`:

```
github "outware/Scenarios"
```

Then run `carthage update`, and integrate `Scenarios.framework` and `Quick.framework` into your test bundle. You can find a handy guide for this [in the Carthage README][Integration Guide].

[Carthage]: https://github.com/Carthage/Carthage
[Integration Guide]: https://github.com/Carthage/Carthage#adding-frameworks-to-unit-tests-or-a-framework

#### Your first feature

Let's use the example above to demonstrate how to test with Scenarios.

Inside your test bundle, create a file called `GreetingFeature.swift`. Delete any Xcode-generated boilerplate and paste in the following (feel free to delete the numbered comments):

```swift
// (1) Feature name
final class GreetingFeature: Feature {
  override func scenarios() {

    // (2) Feature story

    // In order to keep users coming back
    // As a developer
    // I want to greet them warmly when returning to the app

    // (3) A scenario

    Scenario("Greeting on launch")<commit_msg>README: Don't forget Regex.framework when integrating<commit_after># Scenarios

_Human-oriented testing in Swift._

## Introduction

Scenarios is a lightweight wrapper around [Quick][] for writing acceptance tests in BDD style. It's modelled after [Cucumber][].

```swift
final class GreetingFeature: Feature {
  override func scenarios() {

    // In order to keep users coming back
    // As a developer
    // I want to greet them warmly when returning to the app

    Scenario("Greeting on launch")
      .When("the app has launched")
      .Then("the greeting 'Hello, world!' should be on screen")

    Scenario("Personalised greeting")
      .Given("the app has launched")
      .When("I enter 'Friend' as my name")
      .Then("I should see the greeting 'Hello, Friend!' on screen")

  }
}
```

[Quick]: https://github.com/Quick/Quick
[Cucumber]: http://cucumber.io/

When paired with Xcode UI Testing, Scenarios gives you a high-level, user-focused and very expressive way to describe the functionality of your app. Or you can use it to define acceptance tests for your library or framework.

Scenarios isn't a UI testing tool. It's a tool for _organising thought_.

## Getting Started

#### Install

You can install Scenarios as a dynamic framework via [Carthage][]. Just add this to your `Cartfile`:

```
github "outware/Scenarios"
```

Then run `carthage update`, and integrate `Scenarios.framework`, `Regex.framework` and `Quick.framework` into your test bundle. You can find a handy guide for this [in the Carthage README][Integration Guide].

[Carthage]: https://github.com/Carthage/Carthage
[Integration Guide]: https://github.com/Carthage/Carthage#adding-frameworks-to-unit-tests-or-a-framework

#### Your first feature

Let's use the example above to demonstrate how to test with Scenarios.

Inside your test bundle, create a file called `GreetingFeature.swift`. Delete any Xcode-generated boilerplate and paste in the following (feel free to delete the numbered comments):

```swift
// (1) Feature name
final class GreetingFeature: Feature {
  override func scenarios() {

    // (2) Feature story

    // In order to keep users coming back
    // As a developer
    // I want to greet them warmly when returning to the app

    // (3) A scenario

    Scenario("Greeting on launch")
{'fraction_non_alphanumeric': 0.09711517286941203, 'fraction_numerical': 0.0013212948689715921, 'mean_word_length': 3.77602523659306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5842885', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1252, 'n_words': 557}