Cucumber Features

Expand All

Collapse All

@spawn

Feature: List step defs as json


In order to build tools on top of Cucumber
As a tool developer
I want to be able to query a features directory for all the step definitions it contains

Background

  1. Given a directory named "features"
    aruba-0.6.2/lib/aruba/cucumber.rb:20
features/docs/api/list_step_defs_as_json.feature:11

Scenario: Two Ruby step definitions, in the same file

  1. Given a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given(/foo/i)  { }
    Given(/b.r/xm) { }
  2. When I run the following Ruby code:
    features/lib/step_definitions/ruby_steps.rb:1
    require 'cucumber'
    puts Cucumber::StepDefinitions.new.to_json
    
  3. Then it should pass with JSON:
    features/lib/step_definitions/json_steps.rb:1
    [
      {"source": "foo", "flags": "i"},
      {"source": "b.r", "flags": "mx"}
    ]
features/docs/api/list_step_defs_as_json.feature:31

Scenario: Non-default directory structure

  1. Given a file named "my_weird/place/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given(/foo/)  { }
    Given(/b.r/x) { }
  2. When I run the following Ruby code:
    features/lib/step_definitions/ruby_steps.rb:1
    require 'cucumber'
    puts Cucumber::StepDefinitions.new(:autoload_code_paths => ['my_weird']).to_json
    
  3. Then it should pass with JSON:
    features/lib/step_definitions/json_steps.rb:1
    [
      {"source": "foo", "flags": ""},
      {"source": "b.r", "flags": "x"}
    ]
    
@spawn

Feature: Run Cli::Main with existing Runtime


This is the API that Spork uses. It creates an existing runtime then
calls load_programming_language('rb') on it to load the RbDsl.
When the process forks, Spork them passes the runtime to Cli::Main to
run it.

features/docs/api/run_cli_main_with_existing_runtime.feature:9

Scenario: Run a single feature

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. Given a file named "features/success.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: 
      Scenario: 
        Given this step passes
  3. When I run the following Ruby code:
    features/lib/step_definitions/ruby_steps.rb:1
    require 'cucumber'
    runtime = Cucumber::Runtime.new
    runtime.load_programming_language('rb')
    Cucumber::Cli::Main.new([]).execute!(runtime)
    
  4. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7
  5. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Given this step passes

Feature: Dry Run


Dry run gives you a way to quickly scan your features without actually running them.

- Invokes formatters without executing the steps.
- This also omits the loading of your support/env.rb file if it exists.

features/docs/cli/dry_run.feature:8

Scenario: With a failing step

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: test
      Scenario:
        Given this step fails
  2. And the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  3. When I run `cucumber --dry-run`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: test
    
      Scenario:               # features/test.feature:2
        Given this step fails # features/step_definitions/steps.rb:4
    
    1 scenario (1 skipped)
    1 step (1 skipped)
    
features/docs/cli/dry_run.feature:29

Scenario: In strict mode

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: test
      Scenario:
        Given this step fails
  2. And the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  3. When I run `cucumber --dry-run --strict`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: test
    
      Scenario:               # features/test.feature:2
        Given this step fails # features/step_definitions/steps.rb:4
    
    1 scenario (1 skipped)
    1 step (1 skipped)
    
features/docs/cli/dry_run.feature:50

Scenario: In strict mode with an undefined step

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: test
      Scenario:
        Given this step is undefined
  2. When I run `cucumber --dry-run --strict`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: test
    
      Scenario:                      # features/test.feature:2
        Given this step is undefined # features/test.feature:3
          Undefined step: "this step is undefined" (Cucumber::Undefined)
          features/test.feature:3:in `Given this step is undefined'
    
    1 scenario (1 undefined)
    1 step (1 undefined)
    

Feature: Excluding ruby and feature files from runs


Developers are able to easily exclude files from cucumber runs
This is a nice feature to have in conjunction with profiles, so you can exclude
certain environment files from certain runs.

features/docs/cli/exclude_files.feature:7

Scenario: exclude ruby files

  1. Given an empty file named "features/support/dont_require_me.rb"
    aruba-0.6.2/lib/aruba/cucumber.rb:42
  2. And an empty file named "features/step_definitions/fooz.rb"
    aruba-0.6.2/lib/aruba/cucumber.rb:42
  3. And an empty file named "features/step_definitions/foof.rb"
    aruba-0.6.2/lib/aruba/cucumber.rb:42
  4. And an empty file named "features/step_definitions/foot.rb"
    aruba-0.6.2/lib/aruba/cucumber.rb:42
  5. And an empty file named "features/support/require_me.rb"
    aruba-0.6.2/lib/aruba/cucumber.rb:42
  6. When I run `cucumber features -q --verbose --exclude features/support/dont --exclude foo[zf]`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  7. Then "features/support/require_me.rb" should be required
    features/lib/step_definitions/aruba_steps.rb:15
  8. And "features/step_definitions/foot.rb" should be required
    features/lib/step_definitions/aruba_steps.rb:15
  9. And "features/support/dont_require_me.rb" should not be required
    features/lib/step_definitions/aruba_steps.rb:11
  10. And "features/step_definitions/foof.rb" should not be required
    features/lib/step_definitions/aruba_steps.rb:11
  11. And "features/step_definitions/fooz.rb" should not be required
    features/lib/step_definitions/aruba_steps.rb:11

Feature: Tag logic

In order to conveniently run subsets of features
As a Cuker
I want to select features using logical AND/OR of tags

Background

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    @feature
    Feature: Sample
    
      @one @three
      Scenario: Example
        Given passing
    
      @one
      Scenario: Another Example
        Given passing
    
      @three
      Scenario: Yet another Example
        Given passing
    
      @ignore
      Scenario: And yet another Example
features/docs/cli/execute_with_tag_filter.feature:28

Scenario: ANDing tags

  1. When I run `cucumber -q -t @one -t @three features/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    @feature
    Feature: Sample
    
      @one @three
      Scenario: Example
        Given passing
    
    1 scenario (1 undefined)
    1 step (1 undefined)
    
features/docs/cli/execute_with_tag_filter.feature:44

Scenario: ORing tags

  1. When I run `cucumber -q -t @one,@three features/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    @feature
    Feature: Sample
    
      @one @three
      Scenario: Example
        Given passing
    
      @one
      Scenario: Another Example
        Given passing
    
      @three
      Scenario: Yet another Example
        Given passing
    
    3 scenarios (3 undefined)
    3 steps (3 undefined)
    
features/docs/cli/execute_with_tag_filter.feature:68

Scenario: Negative tags

  1. When I run `cucumber -q -t ~@three features/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    @feature
    Feature: Sample
    
      @one
      Scenario: Another Example
        Given passing
    
      @ignore
      Scenario: And yet another Example
    
    2 scenarios (1 undefined, 1 passed)
    1 step (1 undefined)
features/docs/cli/execute_with_tag_filter.feature:86

Scenario: Run with limited tag count, blowing it on scenario

  1. When I run `cucumber -q --no-source --tags @one:1 features/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it fails before running features with:
    features/lib/step_definitions/aruba_steps.rb:19
    @one occurred 2 times, but the limit was set to 1
      features/test.feature:5
      features/test.feature:9
features/docs/cli/execute_with_tag_filter.feature:95

Scenario: Run with limited tag count, blowing it via feature inheritance

  1. When I run `cucumber -q --no-source --tags @feature:1 features/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it fails before running features with:
    features/lib/step_definitions/aruba_steps.rb:19
    @feature occurred 4 times, but the limit was set to 1
      features/test.feature:5
      features/test.feature:9
      features/test.feature:13
      features/test.feature:17
features/docs/cli/execute_with_tag_filter.feature:106

Scenario: Run with limited tag count using negative tag, blowing it via a tag that is not run

  1. When I run `cucumber -q --no-source --tags ~@one:1 features/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it fails before running features with:
    features/lib/step_definitions/aruba_steps.rb:19
    @one occurred 2 times, but the limit was set to 1
features/docs/cli/execute_with_tag_filter.feature:113

Scenario: Limiting with tags which do not exist in the features Originally added to check [Lighthouse bug #464](https://rspec.lighthouseapp.com/projects/16211/tickets/464).

  1. When I run `cucumber -q -t @i_dont_exist features/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7

Feature: Loading the steps users expect

As a User
In order to run features in subdirectories without having to pass extra options
I want cucumber to load all step files

features/docs/cli/finding_steps.feature:6

Scenario:

  1. Given a file named "features/nesting/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Feature in Subdirectory
      Scenario: A step not in the subdirectory
        Given not found in subdirectory
  2. And a file named "features/step_definitions/steps_no_in_subdirectory.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given(/^not found in subdirectory$/) { }
  3. When I run `cucumber -q features/nesting/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Feature in Subdirectory
    
      Scenario: A step not in the subdirectory
        Given not found in subdirectory
    
    1 scenario (1 passed)
    1 step (1 passed)

Feature: Randomize


Use the `--order random` switch to run scenarios in random order.

This is especially helpful for detecting situations where you have state
leaking between scenarios, which can cause flickering or fragile tests.

If you do find a randmon run that exposes dependencies between your tests,
you can reproduce that run by using the seed that's printed at the end of
the test run.

Background

  1. Given a file named "features/bad_practice.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Bad practice
      
      Scenario: Set state
        Given I set some state
    
      Scenario: Depend on state
        When I depend on the state
  2. And a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given(/^I set some state$/) do
      $global_state = "set"
    end
    
    Given(/^I depend on the state$/) do
      raise "I expect the state to be set!" unless $global_state == "set"
    end
features/docs/cli/randomize.feature:34

Scenario: Run scenarios in order

  1. When I run `cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7
@spawnfeatures/docs/cli/randomize.feature:39

Scenario: Run scenarios randomized

  1. When I run `cucumber --order random:41515`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail
    features/lib/step_definitions/aruba_steps.rb:7
  3. And the stdout should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:258
    Randomized with seed 41515

Feature: Requiring extra step files


Cucumber allows you to require extra files using the `-r` option.

features/docs/cli/require.feature:5

Scenario:

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
      Scenario: Sample
        Given found in extra file
  2. And a file named "tmp/extras.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given(/^found in extra file$/) { }
  3. When I run `cucumber -q -r tmp/extras.rb features/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Sample
    
      Scenario: Sample
        Given found in extra file
    
    1 scenario (1 passed)
    1 step (1 passed)

Feature: Run feature elements matching a name with --name/-n


The `--name NAME` option runs only scenarios which match a certain
name. The NAME can be a substring of the names of Features, Scenarios,
Scenario Outlines or Example blocks.

Background

  1. Given a file named "features/first.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: first feature
      Scenario: foo first
        Given missing
      Scenario: bar first
        Given missing
  2. Given a file named "features/second.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: second
      Scenario: foo second
        Given missing
      Scenario: bar second
        Given missing
  3. Given a file named "features/outline.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: outline
      Scenario Outline: baz outline
        Given outline step <name>
    
        Examples: quux example
          | name |
          | a    |
          | b    |
features/docs/cli/run_scenarios_matching_name.feature:36

Scenario: Matching Feature names

  1. When I run `cucumber -q --name feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: first feature
    
      Scenario: foo first
        Given missing
    
      Scenario: bar first
        Given missing
    
    2 scenarios (2 undefined)
    2 steps (2 undefined)
features/docs/cli/run_scenarios_matching_name.feature:52

Scenario: Matching Scenario names

  1. When I run `cucumber -q --name foo`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: first feature
    
      Scenario: foo first
        Given missing
    
    Feature: second
    
      Scenario: foo second
        Given missing
    
    2 scenarios (2 undefined)
    2 steps (2 undefined)
features/docs/cli/run_scenarios_matching_name.feature:70

Scenario: Matching Scenario Outline names

  1. When I run `cucumber -q --name baz`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: outline
    
      Scenario Outline: baz outline
        Given outline step <name>
    
        Examples: quux example
          | name |
          | a    |
          | b    |
    
    2 scenarios (2 undefined)
    2 steps (2 undefined)
features/docs/cli/run_scenarios_matching_name.feature:88

Scenario: Matching Example block names

  1. When I run `cucumber -q --name quux`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: outline
    
      Scenario Outline: baz outline
        Given outline step <name>
    
        Examples: quux example
          | name |
          | a    |
          | b    |
    
    2 scenarios (2 undefined)
    2 steps (2 undefined)

Feature: Run specific scenarios


You can choose to run a specific scenario using the file:line format,
or you can pass in a file with a list of scenarios using @-notation.

The line number can fall anywhere within the body of a scenario, including
steps, tags, comments, description, data tables or doc strings.

For scenario outlines, if the line hits one example row, just that one
will be run. Otherwise all examples in the table or outline will be run.

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
features/docs/cli/run_specific_scenarios.feature:15

Scenario: Two scenarios, run just one of them

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: 
    
      Scenario: Miss
        Given this step is undefined
    
      Scenario: Hit
        Given this step passes
  2. When I run `cucumber features/test.feature:7 --format pretty --quiet`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: 
    
      Scenario: Hit
        Given this step passes
    
    1 scenario (1 passed)
    1 step (1 passed)
    
features/docs/cli/run_specific_scenarios.feature:39

Scenario: Use @-notation to specify a file containing feature file list

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
      Scenario: Passing
        Given this step passes
  2. And a file named "list-of-features.txt" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    features/test.feature:2
  3. When I run `cucumber -q @list-of-features.txt`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Sample
    
      Scenario: Passing
        Given this step passes
    
    1 scenario (1 passed)
    1 step (1 passed)
features/docs/cli/run_specific_scenarios.feature:62

Scenario: Specify order of scenarios

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: 
      Scenario:
        Given this step passes
    
      Scenario:
        Given this step fails
  2. When I run `cucumber features/test.feature:5 features/test.feature:3 -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    F.

Feature: Showing differences to expected output


Cucumber will helpfully show you the expectation error that your
testing library gives you, in the context of the failing scenario.
When using RSpec, for example, this will show the difference between
the expected and the actual output.

features/docs/cli/showing_differences.feature:8

Scenario: Run single failing scenario with default diff enabled

  1. Given a file named "features/failing_expectation.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Failing expectation
    
      Scenario: Failing expectation
        Given failing expectation
  2. And a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given /^failing expectation$/ do x=1
      expect('this').to eq 'that'
    end
  3. When I run `cucumber -q features/failing_expectation.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Failing expectation
    
      Scenario: Failing expectation
        Given failing expectation
          
          expected: "that"
               got: "this"
          
          (compared using ==)
           (RSpec::Expectations::ExpectationNotMetError)
          ./features/step_definitions/steps.rb:2:in `/^failing expectation$/'
          features/failing_expectation.feature:4:in `Given failing expectation'
    
    Failing Scenarios:
    cucumber features/failing_expectation.feature:3
    
    1 scenario (1 failed)
    1 step (1 failed)
@spawn

Feature: Running multiple formatters


When running cucumber, you are able to using multiple different
formatters and redirect the output to text files.
Two formatters cannot both print to the same file (or to STDOUT)

Background

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Lots of undefined
    
      Scenario: Implement me
        Given it snows in Sahara
        Given it's 40 degrees in Norway
        And it's 40 degrees in Norway
        When I stop procrastinating
        And there is world peace
features/docs/cli/specifying_multiple_formatters.feature:21

Scenario: Multiple formatters and outputs

  1. When I run `cucumber --no-color --format progress --out progress.txt --format pretty --out pretty.txt --no-source --dry-run --no-snippets features/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  3. Then the file "progress.txt" should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:343
    UUUUU
    
    1 scenario (1 undefined)
    5 steps (5 undefined)
    
  4. And the file "pretty.txt" should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:343
    Feature: Lots of undefined
    
      Scenario: Implement me
        Given it snows in Sahara
        Given it's 40 degrees in Norway
        And it's 40 degrees in Norway
        When I stop procrastinating
        And there is world peace
    
    1 scenario (1 undefined)
    5 steps (5 undefined)
    
features/docs/cli/specifying_multiple_formatters.feature:48

Scenario: Two formatters to stdout

  1. When I run `cucumber -f progress -f pretty features/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    All but one formatter must use --out, only one can print to each stream (or STDOUT) (RuntimeError)
features/docs/cli/specifying_multiple_formatters.feature:55

Scenario: Two formatters to stdout when using a profile

  1. Given the following profiles are defined:
    features/lib/step_definitions/profile_steps.rb:1
    default: -q
  2. When I run `cucumber -f progress -f pretty features/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    All but one formatter must use --out, only one can print to each stream (or STDOUT) (RuntimeError)

Feature: Strict mode


Using the `--strict` flag will cause cucumber to fail unless all the
step definitions have been defined.

Background

  1. Given a file named "features/missing.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Missing
      Scenario: Missing
        Given this step passes
  2. And a file named "features/pending.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Pending
      Scenario: Pending
        Given this step is pending
features/docs/cli/strict_mode.feature:20

Scenario: Fail with --strict due to undefined step

  1. When I run `cucumber -q features/missing.feature --strict`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Missing
    
      Scenario: Missing
        Given this step passes
          Undefined step: "this step passes" (Cucumber::Undefined)
          features/missing.feature:3:in `Given this step passes'
    
    1 scenario (1 undefined)
    1 step (1 undefined)
features/docs/cli/strict_mode.feature:35

Scenario: Fail with --strict due to pending step

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. When I run `cucumber -q features/pending.feature --strict`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Pending
    
      Scenario: Pending
        Given this step is pending
          TODO (Cucumber::Pending)
          ./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
          features/pending.feature:3:in `Given this step is pending'
    
    1 scenario (1 pending)
    1 step (1 pending)
features/docs/cli/strict_mode.feature:52

Scenario: Succeed with --strict

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. When I run `cucumber -q features/missing.feature --strict`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Missing
    
      Scenario: Missing
        Given this step passes
    
    1 scenario (1 passed)
    1 step (1 passed)

Feature: Nested Steps

Background

  1. Given a scenario with a step that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:7
    Given two turtles
  2. And a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /a turtle/ do
      puts "turtle!"
    end
features/docs/defining_steps/nested_steps.feature:15

Scenario: Use #steps to call several steps at once

  1. Given a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /two turtles/ do
      steps %{
        Given a turtle
        And a turtle
      }
    end
  2. When I run the feature with the progress formatter
    features/lib/step_definitions/cucumber_steps.rb:35
  3. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    turtle!
    
    turtle!
    
features/docs/defining_steps/nested_steps.feature:34

Scenario: Use #step to call a single step

  1. Given a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /two turtles/ do
      step "a turtle"
      step "a turtle"
    end
  2. When I run the feature with the progress formatter
    features/lib/step_definitions/cucumber_steps.rb:35
  3. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    turtle!
    
    turtle!
    
features/docs/defining_steps/nested_steps.feature:51

Scenario: Use #steps to call a table

  1. Given a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /turtles:/ do |table|
      table.hashes.each do |row|
        puts row[:name]
      end
    end
  2. And a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /two turtles/ do
      steps %{
        Given turtles:
          | name      |
          | Sturm     |
          | Liouville |
      }
    end
  3. When I run the feature with the progress formatter
    features/lib/step_definitions/cucumber_steps.rb:35
  4. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Sturm
    
    Liouville
    
features/docs/defining_steps/nested_steps.feature:80

Scenario: Use #steps to call a multi-line string

  1. Given a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
      Given /two turtles/ do
        steps %Q{
          Given turtles:
             """
             Sturm
             Liouville
             """
        }
      end
  2. And a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /turtles:/ do |string|
      puts string
    end
  3. When I run the feature with the progress formatter
    features/lib/step_definitions/cucumber_steps.rb:35
  4. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Sturm
    Liouville
@spawnfeatures/docs/defining_steps/nested_steps.feature:107

Scenario: Backtrace doesn't skip nested steps

  1. Given a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /two turtles/ do
      step "I have a couple turtles"
    end
    
    When(/I have a couple turtles/) { raise 'error' }
  2. When I run the feature with the progress formatter
    features/lib/step_definitions/cucumber_steps.rb:35
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    error (RuntimeError)
    ./features/step_definitions/steps2.rb:5:in `/I have a couple turtles/'
    ./features/step_definitions/steps2.rb:2:in `/two turtles/'
    features/test_feature_1.feature:3:in `Given two turtles'
    
    Failing Scenarios:
    cucumber features/test_feature_1.feature:2 # Scenario: Test Scenario 1
    
    1 scenario (1 failed)
    1 step (1 failed)
features/docs/defining_steps/nested_steps.feature:131

Scenario: Undefined nested step

  1. Given a file named "features/call_undefined_step_from_step_def.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Calling undefined step
    
      Scenario: Call directly
        Given a step that calls an undefined step
    
      Scenario: Call via another
        Given a step that calls a step that calls an undefined step
  2. And a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given /^a step that calls an undefined step$/ do
      step 'this does not exist'
    end
    
    Given /^a step that calls a step that calls an undefined step$/ do
      step 'a step that calls an undefined step'
    end
  3. When I run `cucumber -q features/call_undefined_step_from_step_def.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Calling undefined step
    
      Scenario: Call directly
        Given a step that calls an undefined step
          Undefined dynamic step: "this does not exist" (Cucumber::UndefinedDynamicStep)
          ./features/step_definitions/steps.rb:2:in `/^a step that calls an undefined step$/'
          features/call_undefined_step_from_step_def.feature:4:in `Given a step that calls an undefined step'
    
      Scenario: Call via another
        Given a step that calls a step that calls an undefined step
          Undefined dynamic step: "this does not exist" (Cucumber::UndefinedDynamicStep)
          ./features/step_definitions/steps.rb:2:in `/^a step that calls an undefined step$/'
          ./features/step_definitions/steps.rb:6:in `/^a step that calls a step that calls an undefined step$/'
          features/call_undefined_step_from_step_def.feature:7:in `Given a step that calls a step that calls an undefined step'
    
    Failing Scenarios:
    cucumber features/call_undefined_step_from_step_def.feature:3
    cucumber features/call_undefined_step_from_step_def.feature:6
    
    2 scenarios (2 failed)
    2 steps (2 failed)
    

Feature: Nested Steps in I18n

Background

  1. Given a scenario with a step that looks like this in japanese:
    features/lib/step_definitions/cucumber_steps.rb:13
    前提 two turtles
  2. And a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    # -*- coding: utf-8 -*-
    前提 /a turtle/ do
      puts "turtle!"
    end
features/docs/defining_steps/nested_steps_i18n.feature:16

Scenario: Use #steps to call several steps at once

  1. Given a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    # -*- coding: utf-8 -*-
    前提 /two turtles/ do
      steps %{
        前提 a turtle
        かつ a turtle
      }
    end
  2. When I run the feature with the progress formatter
    features/lib/step_definitions/cucumber_steps.rb:35
  3. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    turtle!
    
    turtle!
    

Feature: Nested Steps with either table or doc string

Background

  1. Given a scenario with a step that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:7
    Given two turtles
features/docs/defining_steps/nested_steps_with_second_arg.feature:9

Scenario: Use #step with table

  1. Given a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /turtles:/ do |table|
      table.hashes.each do |row|
        puts row[:name]
      end
    end
  2. And a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /two turtles/ do
      step %{turtles:}, table(%{
      | name      |
      | Sturm     |
      | Liouville |
      })
    end
  3. When I run the feature with the progress formatter
    features/lib/step_definitions/cucumber_steps.rb:35
  4. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Sturm
    
    Liouville
    
features/docs/defining_steps/nested_steps_with_second_arg.feature:37

Scenario: Use #step with docstring

  1. Given a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /two turtles/ do
      step %{turtles:}, "Sturm and Lioville"
    end
  2. And a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /turtles:/ do |text|
      puts text
    end
  3. When I run the feature with the progress formatter
    features/lib/step_definitions/cucumber_steps.rb:35
  4. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Sturm and Lioville
features/docs/defining_steps/nested_steps_with_second_arg.feature:56

Scenario: Use #step with docstring and content-type

  1. Given a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /two turtles/ do
      step %{turtles:}, doc_string('Sturm and Lioville','math')
    end
  2. And a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /turtles:/ do |text|
      puts text.content_type
    end
  3. When I run the feature with the progress formatter
    features/lib/step_definitions/cucumber_steps.rb:35
  4. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    math

Feature: One line step definitions


Everybody knows you can do step definitions in Cucumber
but did you know you can do this?

features/docs/defining_steps/one_line_step_definitions.feature:6

Scenario: Call a method in World directly from a step def

  1. Given a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    module Driver
      def do_action
        @done = true
      end
    
      def assert_done
        expect(@done).to be true
      end
    end
    World(Driver)
    
    When /I do the action/, :do_action
    Then /The action should be done/, :assert_done
  2. And a file named "features/action.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        When I do the action
        Then the action should be done
  3. When I run `cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7
features/docs/defining_steps/one_line_step_definitions.feature:33

Scenario: Call a method on an actor in the World directly from a step def

  1. Given a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    class Thing
      def do_action
        @done = true
      end
    
      def assert_done
        expect(@done).to be true
      end
    end
    
    module Driver
      def thing
        @thing ||= Thing.new
      end
    end
    World(Driver)
    
    When /I do the action to the thing/, :do_action, :on => lambda { thing }
    Then /The thing should be done/, :assert_done, :on => lambda { thing }
  2. And a file named "features/action.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        When I do the action to the thing
        Then the thing should be done
  3. When I run `cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7

Feature: Pretty formatter - Printing messages


When you want to print to Cucumber's output, just call `puts` from
a step definition. Cucumber will grab the output and print it via
the formatter that you're using.

Your message will be printed out after the step has run.

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. And a file named "features/step_definitions/puts_steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given /^I use puts with text "(.*)"$/ do |ann|
      puts(ann)
    end
    
    Given /^I use multiple putss$/ do
      puts("Multiple")
      puts("Announce","Me")
    end
    
    Given /^I use message (.+) in line (.+) (?:with result (.+))$/ do |ann, line, result|
      puts("Last message") if line == "3"
      puts("Line: #{line}: #{ann}")
      fail if result =~ /fail/i
    end
    
    Given /^I use puts and step fails$/ do
      puts("Announce with fail")
      fail
    end
    
    Given /^I puts the world$/ do
      puts(self)
    end
  3. And a file named "features/f.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
    
      Scenario:
        Given I use puts with text "Ann"
        And this step passes
    
      Scenario:
        Given I use multiple putss
        And this step passes
    
      Scenario Outline:
        Given I use message <ann> in line <line>
    
        Examples:
          | line | ann   |
          | 1    | anno1 |
          | 2    | anno2 |
          | 3    | anno3 |
    
      Scenario:
        Given I use puts and step fails
        And this step passes
    
      Scenario Outline:
        Given I use message <ann> in line <line> with result <result>
    
        Examples:
          | line | ann   | result |
          | 1    | anno1 | fail   |
          | 2    | anno2 | pass   |
  4. And a file named "features/puts_world.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: puts_world
      Scenario: puts_world
        Given I puts the world
# Don't know why, but we need to spawn this for JRuby otherwise it gives wierd errors
@spawnfeatures/docs/defining_steps/printing_messages.feature:80

Scenario: Delayed messages feature

  1. When I run `cucumber --quiet --format pretty features/f.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  3. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Feature: 
    
      Scenario: 
        Given I use puts with text "Ann"
          Ann
        And this step passes
    
      Scenario: 
        Given I use multiple putss
          Multiple
          Announce
          Me
        And this step passes
    
      Scenario Outline: 
        Given I use message <ann> in line <line>
    
        Examples: 
          | line | ann   |
          | 1    | anno1 |
          | 2    | anno2 |
          | 3    | anno3 |
    
      Scenario: 
        Given I use puts and step fails
          Announce with fail
           (RuntimeError)
          ./features/step_definitions/puts_steps.rb:18:in `/^I use puts and step fails$/'
          features/f.feature:21:in `Given I use puts and step fails'
        And this step passes
    
      Scenario Outline: 
        Given I use message <ann> in line <line> with result <result>
    
        Examples: 
          | line | ann   | result |
          | 1    | anno1 | fail   |  Line: 1: anno1
           (RuntimeError)
          ./features/step_definitions/puts_steps.rb:13:in `/^I use message (.+) in line (.+) (?:with result (.+))$/'
          features/f.feature:29:in `Given I use message anno1 in line 1 with result fail'
          features/f.feature:25:in `Given I use message <ann> in line <line> with result <result>'
          | 2    | anno2 | pass   |  Line: 2: anno2
features/docs/defining_steps/printing_messages.feature:129

Scenario: Non-delayed messages feature (progress formatter)

  1. When I run `cucumber --format progress features/f.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Ann
    ..
    Multiple
    
    Announce
    
    Me
    ..UUU
    Announce with fail
    F-
    Line: 1: anno1
    F
    Line: 2: anno2
    .

Feature: Skip Scenario

features/docs/defining_steps/skip_scenario.feature:3

Scenario: With a passing step

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: test
      Scenario: test
        Given this step says to skip
        And this step passes
  2. And the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  3. And a file named "features/step_definitions/skippy.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given /skip/ do
      skip_this_scenario
    end
  4. When I run `cucumber -q`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: test
    
      Scenario: test
        Given this step says to skip
        And this step passes
    
    1 scenario (1 skipped)
    2 steps (2 skipped)
    
features/docs/defining_steps/skip_scenario.feature:32

Scenario: Use legacy API from a hook

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: test
      Scenario: test
        Given this step passes
        And this step passes
  2. And the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  3. And a file named "features/support/hook.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Before do |scenario|
      scenario.skip_invoke!
    end
  4. When I run `cucumber -q`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: test
    
      Scenario: test
        Given this step passes
        And this step passes
    
    1 scenario (1 skipped)
    2 steps (2 skipped)
    

Feature: Snippets


Cucumber helpfully prints out any undefined step definitions as a code
snippet suggestion, which you can then paste into a step definitions
file of your choosing.

features/docs/defining_steps/snippets.feature:7

Scenario: Snippet for undefined step with a pystring

  1. Given a file named "features/undefined_steps.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
    Scenario: pystring
      Given a pystring
      """
        example with <html> entities
      """
      When a simple when step
      And another when step
      Then a simple then step
  2. When I run `cucumber features/undefined_steps.feature -s`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Given(/^a pystring$/) do |string|
      pending # Write code here that turns the phrase above into concrete actions
    end
    
    When(/^a simple when step$/) do
      pending # Write code here that turns the phrase above into concrete actions
    end
    
    When(/^another when step$/) do
      pending # Write code here that turns the phrase above into concrete actions
    end
    
    Then(/^a simple then step$/) do
      pending # Write code here that turns the phrase above into concrete actions
    end
features/docs/defining_steps/snippets.feature:40

Scenario: Snippet for undefined step with a step table

  1. Given a file named "features/undefined_steps.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
    Scenario: table
      Given a table
        | table |
        |example|
  2. When I run `cucumber features/undefined_steps.feature -s`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Given(/^a table$/) do |table|
      # table is a Cucumber::Core::Ast::DataTable
      pending # Write code here that turns the phrase above into concrete actions
    end

Feature: Table diffing


To allow you to more easily compare data in tables, you are able
to easily diff a table with expected data and see the diff in your
output.

features/docs/defining_steps/table_diffing.feature:7

Scenario: Extra row

  1. Given a file named "features/tables.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Tables
      Scenario: Extra row
        Then the table should be:
          | x | y |
          | a | b |
  2. And a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Then /the table should be:/ do |expected| x=1
      expected.diff!(table(%{
        | x | y |
        | a | c |
      }))
    end
  3. When I run `cucumber features/tables.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Tables
    
      Scenario: Extra row         # features/tables.feature:2
        Then the table should be: # features/step_definitions/steps.rb:1
          | x | y |
          | a | b |
          Tables were not identical:
          
            |     x |     y |
            | (-) a | (-) b |
            | (+) a | (+) c |
           (Cucumber::MultilineArgument::DataTable::Different)
          ./features/step_definitions/steps.rb:2:in `/the table should be:/'
          features/tables.feature:3:in `Then the table should be:'
    
    Failing Scenarios:
    cucumber features/tables.feature:2 # Scenario: Extra row
    
    1 scenario (1 failed)
    1 step (1 failed)
    0m0.012s
    

Feature: Transforms


If you see certain phrases repeated over and over in your step definitions, you can
use transforms to factor out that duplication, and make your step definitions simpler.

Background Let's just create a simple feature for testing out Transforms. We also have a Person class that we need to be able to build.

  1. Given a file named "features/foo.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        Given a Person aged 15 with blonde hair
  2. And a file named "features/support/person.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    class Person
      attr_accessor :age
    
      def to_s
        "I am #{age} years old"
      end
    end
features/docs/defining_steps/transforms.feature:27

Scenario: Basic Transform This is the most basic way to use a transform. Notice that the regular expression is pretty much duplicated.

  1. And a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Transform(/a Person aged (\d+)/) do |age|
      person = Person.new
      person.age = age.to_i
      person
    end
    
    Given /^(a Person aged \d+) with blonde hair$/ do |person|
      expect(person.age).to eq 15
    end
  2. When I run `cucumber features/foo.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7
features/docs/defining_steps/transforms.feature:46

Scenario: Re-use Transform's Regular Expression If you keep a reference to the transform, you can use it in your regular expressions to avoid repeating the regular expression.

  1. And a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    A_PERSON = Transform(/a Person aged (\d+)/) do |age|
      person = Person.new
      person.age = age.to_i
      person
    end
    
    Given /^(#{A_PERSON}) with blonde hair$/ do |person|
      expect(person.age).to eq 15
    end
  2. When I run `cucumber features/foo.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7

Feature: Exception in After Block

In order to use custom assertions at the end of each scenario
As a developer
I want exceptions raised in After blocks to be handled gracefully and reported by the formatters

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. And a file named "features/step_definitions/naughty_steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given /^this step does something naughty$/ do x=1
      @naughty = true
    end
  3. And a file named "features/support/env.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    class NaughtyScenarioException < Exception; end
    After do
      if @naughty
        raise NaughtyScenarioException.new("This scenario has been very very naughty")
      end
    end
@spawnfeatures/docs/exception_in_after_hook.feature:25

Scenario: Handle Exception in standard scenario step and carry on

  1. Given a file named "features/naughty_step_in_scenario.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
    
      Scenario: Naughty Step
        Given this step does something naughty
    
      Scenario: Success
        Given this step passes
  2. When I run `cucumber features`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Sample
    
      Scenario: Naughty Step                   # features/naughty_step_in_scenario.feature:3
        Given this step does something naughty # features/step_definitions/naughty_steps.rb:1
          This scenario has been very very naughty (NaughtyScenarioException)
          ./features/support/env.rb:4:in `After'
    
      Scenario: Success        # features/naughty_step_in_scenario.feature:6
        Given this step passes # features/step_definitions/steps.rb:1
    
    Failing Scenarios:
    cucumber features/naughty_step_in_scenario.feature:3 # Scenario: Naughty Step
    
    2 scenarios (1 failed, 1 passed)
    2 steps (2 passed)
    
@spawnfeatures/docs/exception_in_after_hook.feature:58

Scenario: Handle Exception in scenario outline table row and carry on

  1. Given a file named "features/naughty_step_in_scenario_outline.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
    
      Scenario Outline: Naughty Step
        Given this step <Might Work>
    
        Examples:
        | Might Work             |
        | passes                 |
        | does something naughty |
        | passes                 |
    
      Scenario: Success
        Given this step passes
    
  2. When I run `cucumber features -q`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Sample
    
      Scenario Outline: Naughty Step
        Given this step <Might Work>
    
        Examples: 
          | Might Work             |
          | passes                 |
          | does something naughty |
          This scenario has been very very naughty (NaughtyScenarioException)
          ./features/support/env.rb:4:in `After'
          | passes                 |
    
      Scenario: Success
        Given this step passes
    
    Failing Scenarios:
    cucumber features/naughty_step_in_scenario_outline.feature:9
    
    4 scenarios (1 failed, 3 passed)
    4 steps (4 passed)
    
features/docs/exception_in_after_hook.feature:103

Scenario: Handle Exception using the progress format

  1. Given a file named "features/naughty_step_in_scenario.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
    
      Scenario: Naughty Step
        Given this step does something naughty
    
      Scenario: Success
        Given this step passes
  2. When I run `cucumber features --format progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    .F.
    
    Failing Scenarios:
    cucumber features/naughty_step_in_scenario.feature:3 # Scenario: Naughty Step
    
    2 scenarios (1 failed, 1 passed)
    2 steps (2 passed)
    

Feature: Exception in AfterStep Block

In order to use custom assertions at the end of each step
As a developer
I want exceptions raised in AfterStep blocks to be handled gracefully and reported by the formatters

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. And a file named "features/step_definitions/naughty_steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given /^this step does something naughty$/ do x=1
      @naughty = true
    end
  3. And a file named "features/support/env.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    class NaughtyStepException < Exception; end
    AfterStep do
      if @naughty
        raise NaughtyStepException.new("This step has been very very naughty")
      end
    end
features/docs/exception_in_after_step_hook.feature:24

Scenario: Handle Exception in standard scenario step and carry on

  1. Given a file named "features/naughty_step_in_scenario.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
    
      Scenario: Naughty Step
        Given this step does something naughty
    
      Scenario: Success
        Given this step passes
  2. When I run `cucumber features`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Sample
    
      Scenario: Naughty Step                   # features/naughty_step_in_scenario.feature:3
        Given this step does something naughty # features/step_definitions/naughty_steps.rb:1
          This step has been very very naughty (NaughtyStepException)
          ./features/support/env.rb:4:in `AfterStep'
          features/naughty_step_in_scenario.feature:4:in `Given this step does something naughty'
    
      Scenario: Success        # features/naughty_step_in_scenario.feature:6
        Given this step passes # features/step_definitions/steps.rb:1
    
    Failing Scenarios:
    cucumber features/naughty_step_in_scenario.feature:3 # Scenario: Naughty Step
    
    2 scenarios (1 failed, 1 passed)
    2 steps (2 passed)
    
features/docs/exception_in_after_step_hook.feature:57

Scenario: Handle Exception in scenario outline table row and carry on

  1. Given a file named "features/naughty_step_in_scenario_outline.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
    
      Scenario Outline: Naughty Step
        Given this step <Might Work>
    
        Examples:
        | Might Work             |
        | passes                 |
        | does something naughty |
        | passes                 |
    
      Scenario: Success
        Given this step passes
    
  2. When I run `cucumber features`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Sample
    
      Scenario Outline: Naughty Step # features/naughty_step_in_scenario_outline.feature:3
        Given this step <Might Work> # features/naughty_step_in_scenario_outline.feature:4
    
        Examples: 
          | Might Work             |
          | passes                 |
          | does something naughty |
          This step has been very very naughty (NaughtyStepException)
          ./features/support/env.rb:4:in `AfterStep'
          features/naughty_step_in_scenario_outline.feature:9:in `Given this step does something naughty'
          features/naughty_step_in_scenario_outline.feature:4:in `Given this step <Might Work>'
          | passes                 |
    
      Scenario: Success        # features/naughty_step_in_scenario_outline.feature:12
        Given this step passes # features/step_definitions/steps.rb:1
    
    Failing Scenarios:
    cucumber features/naughty_step_in_scenario_outline.feature:9 # Scenario Outline: Naughty Step, Examples (#2)
    
    4 scenarios (1 failed, 3 passed)
    4 steps (4 passed)
    

Feature: Exceptions in Around Hooks


Around hooks are awkward beasts to handle internally.

Right now, if there's an error in your Around hook before you call `block.call`,
we won't even print the steps for the scenario.

This is because that `block.call` invokes all the logic that would tell Cucumber's
UI about the steps in your scenario. If we never reach that code, we'll never be
told about them.

There's another scenario to consider, where the exception occurs after the steps
have been run. How would we want to report in that case?

features/docs/exception_in_around_hook.feature:15

Scenario: Exception before the test case is run

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. And a file named "features/support/env.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Around do |scenario, block|
      fail "this should be reported"
      block.call
    end
  3. And a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        Given this step passes
  4. When I run `cucumber -q`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: 
    
      Scenario: 
      this should be reported (RuntimeError)
      ./features/support/env.rb:2:in `Around'
    
    Failing Scenarios:
    cucumber features/test.feature:2
    
    1 scenario (1 failed)
    0 steps
    
features/docs/exception_in_around_hook.feature:47

Scenario: Exception after the test case is run

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. And a file named "features/support/env.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Around do |scenario, block|
      block.call
      fail "this should be reported"
    end
  3. And a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        Given this step passes
  4. When I run `cucumber -q`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: 
    
      Scenario: 
        Given this step passes
          this should be reported (RuntimeError)
          ./features/support/env.rb:3:in `Around'
    
    Failing Scenarios:
    cucumber features/test.feature:2
    
    1 scenario (1 failed)
    1 step (1 passed)
    

Feature: Exception in Before Block

In order to know with confidence that my before blocks have run OK
As a developer
I want exceptions raised in Before blocks to be handled gracefully and reported by the formatters

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. And a file named "features/support/env.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    class SomeSetupException < Exception; end
    class BadStepException < Exception; end
    Before do
      raise SomeSetupException.new("I cannot even start this scenario")
    end
@spawnfeatures/docs/exception_in_before_hook.feature:18

Scenario: Handle Exception in standard scenario step and carry on

  1. Given a file named "features/naughty_step_in_scenario.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
    
      Scenario: Run a good step
        Given this step passes
  2. When I run `cucumber features`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Sample
    
      Scenario: Run a good step # features/naughty_step_in_scenario.feature:3
      I cannot even start this scenario (SomeSetupException)
      ./features/support/env.rb:4:in `Before'
        Given this step passes  # features/step_definitions/steps.rb:1
    
    Failing Scenarios:
    cucumber features/naughty_step_in_scenario.feature:3 # Scenario: Run a good step
    
    1 scenario (1 failed)
    1 step (1 skipped)
    
features/docs/exception_in_before_hook.feature:44

Scenario: Handle Exception in Before hook for Scenario with Background

  1. Given a file named "features/naughty_step_in_before.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
    
      Background:
        Given this step passes
    
      Scenario: Run a good step
        Given this step passes
  2. When I run `cucumber features`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Sample
    
      Background:              # features/naughty_step_in_before.feature:3
      I cannot even start this scenario (SomeSetupException)
      ./features/support/env.rb:4:in `Before'
        Given this step passes # features/step_definitions/steps.rb:1
    
      Scenario: Run a good step # features/naughty_step_in_before.feature:6
        Given this step passes  # features/step_definitions/steps.rb:1
    
    Failing Scenarios:
    cucumber features/naughty_step_in_before.feature:6 # Scenario: Run a good step
    
    1 scenario (1 failed)
    2 steps (2 skipped)
    0m0.012s
    
features/docs/exception_in_before_hook.feature:77

Scenario: Handle Exception using the progress format

  1. Given a file named "features/naughty_step_in_scenario.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
    
      Scenario: Run a good step
        Given this step passes
  2. When I run `cucumber features --format progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    F-
    
    Failing Scenarios:
    cucumber features/naughty_step_in_scenario.feature:3 # Scenario: Run a good step
    
    1 scenario (1 failed)
    1 step (1 skipped)
    

Feature: Custom filter

features/docs/extending_cucumber/custom_filter.feature:3

Scenario: Add a custom filter via AfterConfiguration hook

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        Given my special step
  2. And a file named "features/support/my_filter.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    require 'cucumber/core/filter'
    
    MakeAnythingPass = Cucumber::Core::Filter.new do
      def test_case(test_case)
        activated_steps = test_case.test_steps.map do |test_step|
          test_step.with_action { }
        end
        test_case.with_steps(activated_steps).describe_to receiver
      end
    end
    
    AfterConfiguration do |config|
      config.filters << MakeAnythingPass.new
    end
  3. When I run `cucumber --strict`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7

Feature: Custom Formatter

Background

  1. Given a file named "features/f.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: I'll use my own
      Scenario: Just print me
        Given this step passes
  2. And the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
features/docs/extending_cucumber/custom_formatter.feature:12

Scenario: Use the new API

  1. Given a file named "features/support/custom_formatter.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    module MyCustom
      class Formatter
        def initialize(runtime, io, options)
          @io = io
        end
    
        def before_test_case(test_case)
          feature = test_case.source.first
          scenario = test_case.source.last
          @io.puts feature.short_name.upcase
          @io.puts "  #{scenario.name.upcase}"
        end
      end
    end
  2. When I run `cucumber features/f.feature --format MyCustom::Formatter`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    I'LL USE MY OWN
      JUST PRINT ME
    
features/docs/extending_cucumber/custom_formatter.feature:38

Scenario: Use the legacy API

  1. Given a file named "features/support/custom_legacy_formatter.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    module MyCustom
      class LegacyFormatter
        def initialize(runtime, io, options)
          @io = io
        end
    
        def before_feature(feature)
          @io.puts feature.short_name.upcase
        end
    
        def scenario_name(keyword, name, file_colon_line, source_indent)
          @io.puts "  #{name.upcase}"
        end
      end
    end
  2. When I run `cucumber features/f.feature --format MyCustom::LegacyFormatter`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    I'LL USE MY OWN
      JUST PRINT ME
    
features/docs/extending_cucumber/custom_formatter.feature:65

Scenario: Use both You can use a specific shim to opt-in to both APIs at once.

  1. Given a file named "features/support/custom_mixed_formatter.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    module MyCustom
      class MixedFormatter
    
        def initialize(runtime, io, options)
          @io = io
        end
    
        def before_test_case(test_case)
          feature = test_case.source.first
          @io.puts feature.short_name.upcase
        end
    
        def scenario_name(keyword, name, file_colon_line, source_indent)
          @io.puts "  #{name.upcase}"
        end
      end
    end
  2. When I run `cucumber features/f.feature --format MyCustom::MixedFormatter`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    I'LL USE MY OWN
      JUST PRINT ME
    

Feature: Debug formatter


In order to help you easily visualise the listener API, you can use
the `debug` formatter that prints the calls to the listener as a
feature is run.

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
features/docs/formatters/debug_formatter.feature:10

Scenario: title

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        Given this step passes
  2. When I run `cucumber -f debug`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  4. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    before_test_case
    before_features
    before_feature
    before_tags
    after_tags
    feature_name
    before_test_step
    after_test_step
    before_test_step
    before_feature_element
    before_tags
    after_tags
    scenario_name
    before_steps
    before_step
    before_step_result
    step_name
    after_step_result
    after_step
    after_test_step
    after_steps
    after_feature_element
    after_test_case
    after_feature
    after_features
    done

Feature: Formatter API: Step file path and line number (Issue #179)

To all reporter to understand location of current executing step let's fetch this information
from step/step_invocation and pass to reporters

features/docs/formatters/formatter_step_file_colon_line.feature:5

Scenario: my own formatter

  1. Given a file named "features/f.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: I'll use my own
      because I'm worth it
      Scenario: just print step current line and feature file name
        Given step at line 4
        Given step at line 5
  2. And a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given(/^step at line (.*)$/) {|line| }
  3. And a file named "features/support/jb/formatter.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    module Jb
      class Formatter
        def initialize(runtime, io, options)
          @io = io
        end
    
        def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
          @io.puts "step result event: #{file_colon_line}"
        end
    
        def step_name(keyword, step_match, status, source_indent, background, file_colon_line)
          @io.puts "step name event: #{file_colon_line}"
        end
      end
    end
  4. When I run `cucumber features/f.feature --format Jb::Formatter`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    step result event: features/f.feature:4
    step name event: features/f.feature:4
    step result event: features/f.feature:5
    step name event: features/f.feature:5
    

Feature: HTML output formatter

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. And a file named "features/scenario_outline_with_undefined_steps.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
    
      Scenario Outline:
        Given this step is undefined
    
      Examples:
        |foo|
        |bar|
  3. And a file named "features/scenario_outline_with_pending_step.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Outline
    
      Scenario Outline: Will it blend?
        Given this step is pending
        And other step
        When I do something with <example>
        Then I should see something
        Examples:
          | example |
          | one     |
          | two     |
          | three   |
  4. And a file named "features/failing_background_step.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Feature with failing background step
    
      Background:
        Given this step fails
    
      Scenario:
        When I do something
        Then I should see something
features/docs/formatters/html_formatter.feature:43

Scenario: an scenario outline, one undefined step, one random example, expand flag on

  1. When I run `cucumber features/scenario_outline_with_undefined_steps.feature --format html --expand `
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7
features/docs/formatters/html_formatter.feature:47

Scenario Outline: an scenario outline, one pending step

  1. When I run `cucumber <file> --format html <flag>`
    features/docs/formatters/html_formatter.feature:48
  2. Then it should pass
    features/docs/formatters/html_formatter.feature:49
  3. And the output should contain:
    features/docs/formatters/html_formatter.feature:50
    makeYellow('scenario_1')
  4. And the output should not contain:
    features/docs/formatters/html_formatter.feature:54
    makeRed('scenario_1')

Examples

file
flag
features/scenario_outline_with_pending_step.feature
--expand
features/scenario_outline_with_pending_step.feature

Examples

file
flag
features/scenario_outline_with_undefined_steps.feature
--expand
features/scenario_outline_with_undefined_steps.feature
features/docs/formatters/html_formatter.feature:69

Scenario: when using a profile the html shouldn't include 'Using the default profile...'

  1. And a file named "cucumber.yml" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
      default: -r features
  2. When I run `cucumber features/scenario_outline_with_undefined_steps.feature --profile default --format html`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7
  4. And the output should not contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:160
    Using the default profile...
features/docs/formatters/html_formatter.feature:81

Scenario: a feature with a failing background step

  1. When I run `cucumber features/failing_background_step.feature --format html`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the output should not contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:160
    makeRed('scenario_0')
  3. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    makeRed('background_0')

Feature: JSON output formatter

In order to simplify processing of Cucumber features and results
Developers should be able to consume features as JSON

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. And a file named "features/one_passing_one_failing.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    @a
    Feature: One passing scenario, one failing scenario
    
      @b
      Scenario: Passing
        Given this step passes
    
      @c
      Scenario: Failing
        Given this step fails
  3. And a file named "features/step_definitions/json_steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given /^I embed a screenshot/ do
      File.open("screenshot.png", "w") { |file| file << "foo" }
      embed "screenshot.png", "image/png"
    end
    
    Given /^I print from step definition/ do
      puts "from step definition"
    end
    
    Given /^I embed data directly/ do
      data = "YWJj"
      embed data, "mime-type;base64"
    end
  4. And a file named "features/embed.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: A screenshot feature
    
      Scenario:
        Given I embed a screenshot
    
  5. And a file named "features/outline.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: An outline feature
    
      Scenario Outline: outline
        Given this step <status>
    
        Examples: examples1
          | status |
          | passes |
          | fails  |
    
        Examples: examples2
          | status |
          | passes |
  6. And a file named "features/print_from_step_definition.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: A print from step definition feature
    
      Scenario:
        Given I print from step definition
        And I print from step definition
    
  7. And a file named "features/print_from_step_definition.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: A print from step definition feature
    
      Scenario:
        Given I print from step definition
        And I print from step definition
    
  8. And a file named "features/embed_data_directly.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: An embed data directly feature
    
      Scenario:
        Given I embed data directly
    
      Scenario Outline:
        Given I embed data directly
    
    Examples:
    | dummy |
    |  1    |
    |  2    |
    
  9. And a file named "features/out_scenario_out_scenario_outline.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        Given this step passes
      Scenario Outline:
        Given this step <status>
        Examples:
        | status |
        | passes |
# Need to investigate why this won't pass in-process. error_message doesn't get det?
@spawnfeatures/docs/formatters/json_formatter.feature:108

Scenario: one feature, one passing scenario, one failing scenario

  1. When I run `cucumber --format json features/one_passing_one_failing.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with JSON:
    features/lib/step_definitions/json_steps.rb:1
    [
      {
        "uri": "features/one_passing_one_failing.feature",
        "keyword": "Feature",
        "id": "one-passing-scenario,-one-failing-scenario",
        "name": "One passing scenario, one failing scenario",
        "line": 2,
        "description": "",
        "tags": [
          {
            "name": "@a",
            "line": 1
          }
        ],
        "elements": [
          {
            "keyword": "Scenario",
            "id": "one-passing-scenario,-one-failing-scenario;passing",
            "name": "Passing",
            "line": 5,
            "description": "",
            "tags": [
              {
                "name": "@a",
                "line": 1
              },
              {
                "name": "@b",
                "line": 4
              }
            ],
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "this step passes",
                "line": 6,
                "match": {
                  "location": "features/step_definitions/steps.rb:1"
                },
                "result": {
                  "status": "passed",
                  "duration": 1
                }
              }
            ]
          },
          {
            "keyword": "Scenario",
            "id": "one-passing-scenario,-one-failing-scenario;failing",
            "name": "Failing",
            "line": 9,
            "description": "",
            "tags": [
              {
                "name": "@a",
                "line": 1
              },
              {
                "name": "@c",
                "line": 8
              }
            ],
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "this step fails",
                "line": 10,
                "match": {
                  "location": "features/step_definitions/steps.rb:4"
                },
                "result": {
                  "status": "failed",
                  "error_message": " (RuntimeError)\n./features/step_definitions/steps.rb:4:in `/^this step fails$/'\nfeatures/one_passing_one_failing.feature:10:in `Given this step fails'",
                  "duration": 1
                }
              }
            ]
          }
        ]
      }
    ]
    
@spawnfeatures/docs/formatters/json_formatter.feature:199

Scenario: one feature, one passing scenario, one failing scenario with prettyfied json

  1. When I run `cucumber --format json_pretty features/one_passing_one_failing.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with JSON:
    features/lib/step_definitions/json_steps.rb:1
    [
      {
        "uri": "features/one_passing_one_failing.feature",
        "keyword": "Feature",
        "id": "one-passing-scenario,-one-failing-scenario",
        "name": "One passing scenario, one failing scenario",
        "line": 2,
        "description": "",
        "tags": [
          {
            "name": "@a",
            "line": 1
          }
        ],
        "elements": [
          {
            "keyword": "Scenario",
            "id": "one-passing-scenario,-one-failing-scenario;passing",
            "name": "Passing",
            "line": 5,
            "description": "",
            "tags": [
              {
                "name": "@a",
                "line": 1
              },
              {
                "name": "@b",
                "line": 4
              }
            ],
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "this step passes",
                "line": 6,
                "match": {
                  "location": "features/step_definitions/steps.rb:1"
                },
                "result": {
                  "status": "passed",
                  "duration": 1
                }
              }
            ]
          },
          {
            "keyword": "Scenario",
            "id": "one-passing-scenario,-one-failing-scenario;failing",
            "name": "Failing",
            "line": 9,
            "description": "",
            "tags": [
              {
                "name": "@a",
                "line": 1
              },
              {
                "name": "@c",
                "line": 8
              }
            ],
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "this step fails",
                "line": 10,
                "match": {
                  "location": "features/step_definitions/steps.rb:4"
                },
                "result": {
                  "status": "failed",
                  "error_message": " (RuntimeError)\n./features/step_definitions/steps.rb:4:in `/^this step fails$/'\nfeatures/one_passing_one_failing.feature:10:in `Given this step fails'",
                  "duration": 1
                }
              }
            ]
          }
        ]
      }
    ]
    
@spawnfeatures/docs/formatters/json_formatter.feature:290

Scenario: DocString

  1. Given a file named "features/doc_string.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: A DocString feature
    
      Scenario:
        Then I should fail with
          """
          a string
          """
  2. And a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Then /I should fail with/ do |s|
      raise RuntimeError, s
    end
  3. When I run `cucumber --format json features/doc_string.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should fail with JSON:
    features/lib/step_definitions/json_steps.rb:1
    [
      {
        "id": "a-docstring-feature",
        "uri": "features/doc_string.feature",
        "keyword": "Feature",
        "name": "A DocString feature",
        "line": 1,
        "description": "",
        "elements": [
          {
            "id": "a-docstring-feature;",
            "keyword": "Scenario",
            "name": "",
            "line": 3,
            "description": "",
            "type": "scenario",
            "steps": [
              {
                "keyword": "Then ",
                "name": "I should fail with",
                "line": 4,
                "doc_string": {
                  "content_type": "",
                  "value": "a string",
                  "line": 5
                },
                "match": {
                  "location": "features/step_definitions/steps.rb:1"
                },
                "result": {
                  "status": "failed",
                  "error_message": "a string (RuntimeError)\n./features/step_definitions/steps.rb:2:in `/I should fail with/'\nfeatures/doc_string.feature:4:in `Then I should fail with'",
                  "duration": 1
                }
              }
            ]
          }
        ]
      }
    ]
@spawnfeatures/docs/formatters/json_formatter.feature:353

Scenario: embedding screenshot

  1. When I run `cucumber -b --format json features/embed.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with JSON:
    features/lib/step_definitions/json_steps.rb:1
    [
      {
        "uri": "features/embed.feature",
        "id": "a-screenshot-feature",
        "keyword": "Feature",
        "name": "A screenshot feature",
        "line": 1,
        "description": "",
        "elements": [
          {
            "id": "a-screenshot-feature;",
            "keyword": "Scenario",
            "name": "",
            "line": 3,
            "description": "",
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "I embed a screenshot",
                "line": 4,
                "embeddings": [
                  {
                    "mime_type": "image/png",
                    "data": "Zm9v"
                  }
                ],
                "match": {
                  "location": "features/step_definitions/json_steps.rb:1"
                },
                "result": {
                  "status": "passed",
                  "duration": 1
                }
              }
            ]
          }
        ]
      }
    ]
    
@spawnfeatures/docs/formatters/json_formatter.feature:401

Scenario: scenario outline

  1. When I run `cucumber --format json features/outline.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with JSON:
    features/lib/step_definitions/json_steps.rb:1
    [
      {
        "uri": "features/outline.feature",
        "id": "an-outline-feature",
        "keyword": "Feature",
        "name": "An outline feature",
        "line": 1,
        "description": "",
        "elements": [
          {
            "id": "an-outline-feature;outline;examples1;2",
            "keyword": "Scenario Outline",
            "name": "outline",
            "description": "",
            "line": 8,
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "this step passes",
                "line": 8,
                "match": {
                  "location": "features/step_definitions/steps.rb:1"
                },
                "result": {
                  "status": "passed",
                  "duration": 1
                }
              }
            ]
          },
          {
            "id": "an-outline-feature;outline;examples1;3",
            "keyword": "Scenario Outline",
            "name": "outline",
            "description": "",
            "line": 9,
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "this step fails",
                "line": 9,
                "match": {
                  "location": "features/step_definitions/steps.rb:4"
                },
                "result": {
                  "status": "failed",
                  "error_message": " (RuntimeError)\n./features/step_definitions/steps.rb:4:in `/^this step fails$/'\nfeatures/outline.feature:9:in `Given this step fails'\nfeatures/outline.feature:4:in `Given this step <status>'",
                  "duration": 1
                }
              }
            ]
          },
          {
            "id": "an-outline-feature;outline;examples2;2",
            "keyword": "Scenario Outline",
            "name": "outline",
            "description": "",
            "line": 13,
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "this step passes",
                "line": 13,
                "match": {
                  "location": "features/step_definitions/steps.rb:1"
                },
                "result": {
                  "status": "passed",
                  "duration": 1
                }
              }
            ]
          }
        ]
      }
    ]
    
features/docs/formatters/json_formatter.feature:487

Scenario: print from step definition

  1. When I run `cucumber --format json features/print_from_step_definition.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with JSON:
    features/lib/step_definitions/json_steps.rb:1
    [
      {
        "uri": "features/print_from_step_definition.feature",
        "id": "a-print-from-step-definition-feature",
        "keyword": "Feature",
        "name": "A print from step definition feature",
        "line": 1,
        "description": "",
        "elements": [
          {
            "id": "a-print-from-step-definition-feature;",
            "keyword": "Scenario",
            "name": "",
            "line": 3,
            "description": "",
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "I print from step definition",
                "line": 4,
                "output": [
                  "from step definition"
                ],
                "match": {
                  "location": "features/step_definitions/json_steps.rb:6"
                },
                "result": {
                  "status": "passed",
                  "duration": 1
                }
              },
              {
                "keyword": "And ",
                "name": "I print from step definition",
                "line": 5,
                "output": [
                  "from step definition"
                ],
                "match": {
                  "location": "features/step_definitions/json_steps.rb:6"
                },
                "result": {
                  "status": "passed",
                  "duration": 1
                }
              }
            ]
          }
        ]
      }
    ]
    
@spawnfeatures/docs/formatters/json_formatter.feature:547

Scenario: scenario outline expanded

  1. When I run `cucumber --expand --format json features/outline.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with JSON:
    features/lib/step_definitions/json_steps.rb:1
    [
      {
        "uri": "features/outline.feature",
        "id": "an-outline-feature",
        "keyword": "Feature",
        "name": "An outline feature",
        "line": 1,
        "description": "",
        "elements": [
          {
            "id": "an-outline-feature;outline;examples1;2",
            "keyword": "Scenario Outline",
            "name": "outline",
            "line": 8,
            "description": "",
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "this step passes",
                "line": 8,
                "match": {
                  "location": "features/step_definitions/steps.rb:1"
                },
                "result": {
                  "status": "passed",
                  "duration": 1
                }
              }
            ]
          },
          {
            "id": "an-outline-feature;outline;examples1;3",
            "keyword": "Scenario Outline",
            "name": "outline",
            "line": 9,
            "description": "",
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "this step fails",
                "line": 9,
                "match": {
                  "location": "features/step_definitions/steps.rb:4"
                },
                "result": {
                  "status": "failed",
                  "error_message" : " (RuntimeError)\n./features/step_definitions/steps.rb:4:in `/^this step fails$/'\nfeatures/outline.feature:9:in `Given this step fails'\nfeatures/outline.feature:4:in `Given this step <status>'",
    "duration": 1
                }
              }
            ]
          },
          {
            "id": "an-outline-feature;outline;examples2;2",
            "keyword": "Scenario Outline",
            "name": "outline",
            "line": 13,
            "description": "",
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "this step passes",
                "line": 13,
                "match": {
                  "location": "features/step_definitions/steps.rb:1"
                },
                "result": {
                  "status": "passed",
                  "duration": 1
                }
              }
            ]
          }
        ]
      }
    ]
    
@spawnfeatures/docs/formatters/json_formatter.feature:634

Scenario: embedding data directly

  1. When I run `cucumber -b --format json -x features/embed_data_directly.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with JSON:
    features/lib/step_definitions/json_steps.rb:1
    [
      {
        "uri": "features/embed_data_directly.feature",
        "id": "an-embed-data-directly-feature",
        "keyword": "Feature",
        "name": "An embed data directly feature",
        "line": 1,
        "description": "",
        "elements": [
          {
            "id": "an-embed-data-directly-feature;",
            "keyword": "Scenario",
            "name": "",
            "line": 3,
            "description": "",
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "I embed data directly",
                "line": 4,
                "embeddings": [
                  {
      "mime_type": "mime-type",
      "data": "YWJj"
                  }
                ],
                "match": {
                  "location": "features/step_definitions/json_steps.rb:10"
                },
                "result": {
                  "status": "passed",
                  "duration": 1
                }
              }
            ]
          },
          {
            "keyword": "Scenario Outline",
            "name": "",
            "line": 11,
            "description": "",
            "id": "an-embed-data-directly-feature;;;2",
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "I embed data directly",
                "line": 11,
                "embeddings": [
                  {
                    "mime_type": "mime-type",
                    "data": "YWJj"
                  }
                ],
                "match": {
                  "location": "features/step_definitions/json_steps.rb:10"
                },
                "result": {
                  "status": "passed",
                  "duration": 1
                }
              }
            ]
          },
          {
            "keyword": "Scenario Outline",
            "name": "",
            "line": 12,
            "description": "",
            "id": "an-embed-data-directly-feature;;;3",
            "type": "scenario",
            "steps": [
              {
                "keyword": "Given ",
                "name": "I embed data directly",
                "line": 12,
                "embeddings": [
                  {
                    "mime_type": "mime-type",
                    "data": "YWJj"
                  }
                ],
                "match": {
                  "location": "features/step_definitions/json_steps.rb:10"
                },
                "result": {
                  "status": "passed",
                  "duration": 1
                }
              }
            ]
          }
        ]
      }
    ]
    
@spawnfeatures/docs/formatters/json_formatter.feature:737

Scenario: handle output from hooks

  1. Given a file named "features/step_definitions/output_steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Before do
      puts "Before hook 1"
      embed "src", "mime_type", "label"
    end
    
    Before do
      puts "Before hook 2"
      embed "src", "mime_type", "label"
    end
    
    AfterStep do
      puts "AfterStep hook 1"
      embed "src", "mime_type", "label"
    end
    
    AfterStep do
      puts "AfterStep hook 2"
      embed "src", "mime_type", "label"
    end
    
    After do
      puts "After hook 1"
      embed "src", "mime_type", "label"
    end
    
    After do
      puts "After hook 2"
      embed "src", "mime_type", "label"
    end
  2. When I run `cucumber --format json features/out_scenario_out_scenario_outline.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7
@spawn

Feature: JUnit output formatter

In order for developers to create test reports with ant
Cucumber should be able to output JUnit xml files

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. And a file named "features/one_passing_one_failing.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: One passing scenario, one failing scenario
    
      Scenario: Passing
        Given this step passes
    
      Scenario: Failing
        Given this step fails
  3. And a file named "features/some_subdirectory/one_passing_one_failing.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Subdirectory - One passing scenario, one failing scenario
    
      Scenario: Passing
        Given this step passes
    
      Scenario: Failing
        Given this step fails
  4. And a file named "features/pending.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Pending step
    
      Scenario: Pending
        Given this step is pending
    
      Scenario: Undefined
        Given this step is undefined
  5. And a file named "features/pending.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Pending step
    
      Scenario: Pending
        Given this step is pending
    
      Scenario: Undefined
        Given this step is undefined
  6. And a file named "features/scenario_outline.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Scenario outlines
    
      Scenario Outline: Using scenario outlines
        Given this step <type>
    
        Examples:
          | type         |
          | passes       |
          | fails        |
          | is pending   |
          | is undefined |
features/docs/formatters/junit_formatter.feature:63

Scenario: one feature, one passing scenario, one failing scenario

  1. When I run `cucumber --format junit --out tmp/ features/one_passing_one_failing.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
  3. And the junit output file "tmp/TEST-features-one_passing_one_failing.xml" should contain:
    features/lib/step_definitions/junit_steps.rb:1
    <?xml version="1.0" encoding="UTF-8"?>
    <testsuite failures="1" errors="0" skipped="0" tests="2" time="0.05" name="One passing scenario, one failing scenario">
    <testcase classname="One passing scenario, one failing scenario" name="Passing" time="0.05">
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    <testcase classname="One passing scenario, one failing scenario" name="Failing" time="0.05">
      <failure message="failed Failing" type="failed">
        <![CDATA[Scenario: Failing
    
    Given this step fails
    
    Message:
    ]]>
        <![CDATA[ (RuntimeError)
    ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
    features/one_passing_one_failing.feature:7:in `Given this step fails']]>
      </failure>
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    </testsuite>
    
features/docs/formatters/junit_formatter.feature:104

Scenario: one feature in a subdirectory, one passing scenario, one failing scenario

  1. When I run `cucumber --format junit --out tmp/ features/some_subdirectory/one_passing_one_failing.feature --require features`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
  3. And the junit output file "tmp/TEST-features-some_subdirectory-one_passing_one_failing.xml" should contain:
    features/lib/step_definitions/junit_steps.rb:1
    <?xml version="1.0" encoding="UTF-8"?>
    <testsuite failures="1" errors="0" skipped="0" tests="2" time="0.05" name="Subdirectory - One passing scenario, one failing scenario">
    <testcase classname="Subdirectory - One passing scenario, one failing scenario" name="Passing" time="0.05">
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    <testcase classname="Subdirectory - One passing scenario, one failing scenario" name="Failing" time="0.05">
      <failure message="failed Failing" type="failed">
        <![CDATA[Scenario: Failing
    
    Given this step fails
    
    Message:
    ]]>
        <![CDATA[ (RuntimeError)
    ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
    features/some_subdirectory/one_passing_one_failing.feature:7:in `Given this step fails']]>
      </failure>
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    </testsuite>
    
features/docs/formatters/junit_formatter.feature:145

Scenario: pending and undefined steps are reported as skipped

  1. When I run `cucumber --format junit --out tmp/ features/pending.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
  3. And the junit output file "tmp/TEST-features-pending.xml" should contain:
    features/lib/step_definitions/junit_steps.rb:1
    <?xml version="1.0" encoding="UTF-8"?>
    <testsuite failures="0" errors="0" skipped="2" tests="2" time="0.05" name="Pending step">
    <testcase classname="Pending step" name="Pending" time="0.05">
      <skipped/>
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    <testcase classname="Pending step" name="Undefined" time="0.05">
      <skipped/>
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    </testsuite>
    
features/docs/formatters/junit_formatter.feature:177

Scenario: pending and undefined steps with strict option should fail

  1. When I run `cucumber --format junit --out tmp/ features/pending.feature --strict`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
  3. And the junit output file "tmp/TEST-features-pending.xml" should contain:
    features/lib/step_definitions/junit_steps.rb:1
    <?xml version="1.0" encoding="UTF-8"?>
    <testsuite failures="2" errors="0" skipped="0" tests="2" time="0.05" name="Pending step">
    <testcase classname="Pending step" name="Pending" time="0.05">
      <failure message="pending Pending" type="pending">
        <![CDATA[Scenario: Pending
    
    Given this step is pending
    
    Message:
    ]]>
        <![CDATA[TODO (Cucumber::Pending)
    ./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
    features/pending.feature:4:in `Given this step is pending']]>
      </failure>
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    <testcase classname="Pending step" name="Undefined" time="0.05">
      <failure message="undefined Undefined" type="undefined">
        <![CDATA[Scenario: Undefined
    
    Given this step is undefined
    
    Message:
    ]]>
        <![CDATA[Undefined step: "this step is undefined" (Cucumber::Core::Test::Result::Undefined)
    features/pending.feature:7:in `Given this step is undefined']]>
      </failure>
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    </testsuite>
    
features/docs/formatters/junit_formatter.feature:228

Scenario: run all features

  1. When I run `cucumber --format junit --out tmp/ features`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
  3. And a file named "tmp/TEST-features-one_passing_one_failing.xml" should exist
    aruba-0.6.2/lib/aruba/cucumber.rb:307
  4. And a file named "tmp/TEST-features-pending.xml" should exist
    aruba-0.6.2/lib/aruba/cucumber.rb:307
features/docs/formatters/junit_formatter.feature:237

Scenario: show correct error message if no --out is passed

  1. When I run `cucumber --format junit features`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the stderr should not contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:270
    can't convert .* into String \(TypeError\)
  3. And the stderr should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:234
    You *must* specify --out DIR for the junit formatter
features/docs/formatters/junit_formatter.feature:248

Scenario: strict mode, one feature, one scenario outline, four examples: one passing, one failing, one pending, one undefined

  1. When I run `cucumber --strict --format junit --out tmp/ features/scenario_outline.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
  3. And the junit output file "tmp/TEST-features-scenario_outline.xml" should contain:
    features/lib/step_definitions/junit_steps.rb:1
    <?xml version="1.0" encoding="UTF-8"?>
    <testsuite failures="3" errors="0" skipped="0" tests="4" time="0.05" name="Scenario outlines">
    <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | passes |)" time="0.05">
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | fails |)" time="0.05">
      <failure message="failed Using scenario outlines (outline example : | fails |)" type="failed">
        <![CDATA[Scenario Outline: Using scenario outlines
    
    Example row: | fails |
    
    Message:
    ]]>
        <![CDATA[ (RuntimeError)
    ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
    features/scenario_outline.feature:9:in `Given this step fails'
    features/scenario_outline.feature:4:in `Given this step <type>']]>
      </failure>
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | is pending |)" time="0.05">
      <failure message="pending Using scenario outlines (outline example : | is pending |)" type="pending">
        <![CDATA[Scenario Outline: Using scenario outlines
    
    Example row: | is pending |
    
    Message:
    ]]>
        <![CDATA[TODO (Cucumber::Pending)
    ./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
    features/scenario_outline.feature:10:in `Given this step is pending'
    features/scenario_outline.feature:4:in `Given this step <type>']]>
      </failure>
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | is undefined |)" time="0.05">
      <failure message="undefined Using scenario outlines (outline example : | is undefined |)" type="undefined">
        <![CDATA[Scenario Outline: Using scenario outlines
    
    Example row: | is undefined |
    
    Message:
    ]]>
        <![CDATA[Undefined step: "this step is undefined" (Cucumber::Core::Test::Result::Undefined)
    features/scenario_outline.feature:11:in `Given this step is undefined'
    features/scenario_outline.feature:4:in `Given this step <type>']]>
      </failure>
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    </testsuite>
    
features/docs/formatters/junit_formatter.feature:329

Scenario: strict mode with --expand option, one feature, one scenario outline, four examples: one passing, one failing, one pending, one undefined

  1. When I run `cucumber --strict --expand --format junit --out tmp/ features/scenario_outline.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
  3. And the junit output file "tmp/TEST-features-scenario_outline.xml" should contain:
    features/lib/step_definitions/junit_steps.rb:1
    <?xml version="1.0" encoding="UTF-8"?>
    <testsuite failures="3" errors="0" skipped="0" tests="4" time="0.05" name="Scenario outlines">
    <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | passes |)" time="0.05">
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | fails |)" time="0.05">
      <failure message="failed Using scenario outlines (outline example : | fails |)" type="failed">
        <![CDATA[Scenario Outline: Using scenario outlines
    
    Example row: | fails |
    
    Message:
    ]]>
        <![CDATA[ (RuntimeError)
    ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
    features/scenario_outline.feature:9:in `Given this step fails'
    features/scenario_outline.feature:4:in `Given this step <type>']]>
      </failure>
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | is pending |)" time="0.05">
      <failure message="pending Using scenario outlines (outline example : | is pending |)" type="pending">
        <![CDATA[Scenario Outline: Using scenario outlines
    
    Example row: | is pending |
    
    Message:
    ]]>
        <![CDATA[TODO (Cucumber::Pending)
    ./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
    features/scenario_outline.feature:10:in `Given this step is pending'
    features/scenario_outline.feature:4:in `Given this step <type>']]>
      </failure>
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | is undefined |)" time="0.05">
      <failure message="undefined Using scenario outlines (outline example : | is undefined |)" type="undefined">
        <![CDATA[Scenario Outline: Using scenario outlines
    
    Example row: | is undefined |
    
    Message:
    ]]>
        <![CDATA[Undefined step: "this step is undefined" (Cucumber::Core::Test::Result::Undefined)
    features/scenario_outline.feature:11:in `Given this step is undefined'
    features/scenario_outline.feature:4:in `Given this step <type>']]>
      </failure>
      <system-out>
        <![CDATA[]]>
      </system-out>
      <system-err>
        <![CDATA[]]>
      </system-err>
    </testcase>
    </testsuite>
    

Feature: Pretty output formatter

Background

  1. Given a file named "features/scenario_outline_with_undefined_steps.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
    
      Scenario Outline:
        Given this step is undefined
    
      Examples:
        |foo|
        |bar|
features/docs/formatters/pretty_formatter.feature:16

Scenario: an scenario outline, one undefined step, one random example, expand flag on

  1. When I run `cucumber features/scenario_outline_with_undefined_steps.feature --format pretty --expand `
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7
features/docs/formatters/pretty_formatter.feature:20

Scenario: when using a profile the output should include 'Using the default profile...'

  1. And a file named "cucumber.yml" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
      default: -r features
  2. When I run `cucumber --profile default --format pretty`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7
  4. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Using the default profile...
features/docs/formatters/pretty_formatter.feature:31

Scenario: Hook output should be printed before hook exception

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. And a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        Given this step passes
  3. And a file named "features/step_definitions/output_steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Before do
      puts "Before hook"
     end
    
    AfterStep do
      puts "AfterStep hook"
    end
    
    After do
      puts "After hook"
    raise "error"
    end
  4. When I run `cucumber -q -f pretty features/test.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  6. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: 
    
      Scenario: 
          Before hook
        Given this step passes
          AfterStep hook
          After hook
          error (RuntimeError)
          ./features/step_definitions/output_steps.rb:11:in `After'
    
    Failing Scenarios:
    cucumber features/test.feature:2
    
    1 scenario (1 failed)
    1 step (1 passed)

Feature: Progress output formatter

Background

  1. Given a file named "features/scenario_outline_with_undefined_steps.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
    
      Scenario Outline:
        Given this step is undefined
    
      Examples:
        |foo|
        |bar|
features/docs/formatters/progress_formatter.feature:16

Scenario: an scenario outline, one undefined step, one random example, expand flag on

  1. When I run `cucumber features/scenario_outline_with_undefined_steps.feature --format progress --expand `
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7
features/docs/formatters/progress_formatter.feature:20

Scenario: when using a profile the output should include 'Using the default profile...'

  1. And a file named "cucumber.yml" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
      default: -r features
  2. When I run `cucumber --profile default --format progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7
  4. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Using the default profile...

Feature: Rerun formatter


The rerun formatter writes an output that's perfect for
passing to Cucumber when you want to rerun only the
scenarios that prevented the exit code to be zero.

You can save off the rerun output to a file by using it like this:

`cucumber -f rerun --out .cucumber.rerun`

Now you can pass that file's content to Cucumber to tell it
which scenarios to run:

`cucumber \`cat .cucumber.rerun\``

This is useful when debugging in a large suite of features.

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
features/docs/formatters/rerun_formatter.feature:21

Scenario: Exit code is zero

  1. Given a file named "features/mixed.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Mixed
    
      Scenario:
        Given this step is undefined
    
      Scenario:
        Given this step is pending
    
      Scenario:
        Given this step passes
    
  2. When I run `cucumber -f rerun`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
features/docs/formatters/rerun_formatter.feature:42

Scenario: Exit code is zero in the dry-run mode

  1. Given a file named "features/mixed.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Mixed
    
      Scenario:
        Given this step fails
    
      Scenario:
        Given this step is undefined
    
      Scenario:
        Given this step is pending
    
      Scenario:
        Given this step passes
    
  2. And a file named "features/all_good.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: All good
    
      Scenario:
        Given this step passes
  3. When I run `cucumber -f rerun --dry-run`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
features/docs/formatters/rerun_formatter.feature:73

Scenario: Exit code is not zero, regular scenario

  1. Given a file named "features/mixed.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Mixed
    
      Scenario:
        Given this step fails
    
      Scenario:
        Given this step is undefined
    
      Scenario:
        Given this step is pending
    
      Scenario:
        Given this step passes
    
  2. And a file named "features/all_good.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: All good
    
      Scenario:
        Given this step passes
  3. When I run `cucumber -f rerun --strict`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    features/mixed.feature:3:6:9
features/docs/formatters/rerun_formatter.feature:105

Scenario: Exit code is not zero, scenario outlines For details see https://github.com/cucumber/cucumber/issues/57

  1. Given a file named "features/one_passing_one_failing.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: One passing example, one failing example
    
      Scenario Outline:
        Given this step <status>
      
      Examples:
        | status |
        | passes |
        | fails  |
    
  2. When I run `cucumber -f rerun`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    features/one_passing_one_failing.feature:9
features/docs/formatters/rerun_formatter.feature:126

Scenario: Exit code is not zero, failing background

  1. Given a file named "features/failing_background.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Failing background sample
    
      Background:
        Given this step fails
    
      Scenario: failing background
        Then this step passes
    
      Scenario: another failing background
        Then this step passes
  2. When I run `cucumber -f rerun`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    features/failing_background.feature:6:9
features/docs/formatters/rerun_formatter.feature:146

Scenario: Exit code is not zero, failing background with scenario outline

  1. Given a file named "features/failing_background_outline.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Failing background sample with scenario outline
    
      Background:
        Given this step fails
    
      Scenario Outline:
        Then this step <status>
    
      Examples:
        | status |
        | passes |
        | passes |
  2. When I run `cucumber features/failing_background_outline.feature -r features -f rerun`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    features/failing_background_outline.feature:11:12
features/docs/formatters/rerun_formatter.feature:168

Scenario: Exit code is not zero, scenario outlines with expand For details see https://github.com/cucumber/cucumber/issues/503

  1. Given a file named "features/one_passing_one_failing.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
      Feature: One passing example, one failing example
    
        Scenario Outline:
          Given this step <status>
    
        Examples:
          | status |
          | passes |
          | fails  |
    
  2. When I run `cucumber --expand -f rerun`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    features/one_passing_one_failing.feature:9

Feature: Usage formatter


In order to see where step definitions are used
Developers should be able to see a list of step definitions and their use

Background

  1. Given a file named "features/f.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: F
      Background: A
        Given A
      Scenario: B
        Given B
      Scenario Outline: CA
        Given <x>
        And B
        Examples:
          |x|
          |C|
          |A|
      Scenario: AC
        Given A
        Given C
  2. And a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given(/A/) { }
    Given(/B/) { }
    Given(/C/) { }
    Given(/D/) { }
features/docs/formatters/usage_formatter.feature:33

Scenario: Run with --format usage

  1. When I run `cucumber -f usage --dry-run`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    -----------
    
    /A/       # features/step_definitions/steps.rb:1
      Given A # features/f.feature:3
      Given A # features/f.feature:12
      Given A # features/f.feature:14
    /B/       # features/step_definitions/steps.rb:2
      Given B # features/f.feature:5
      And B   # features/f.feature:11
      And B   # features/f.feature:12
    /C/       # features/step_definitions/steps.rb:3
      Given C # features/f.feature:11
      Given C # features/f.feature:15
    /D/       # features/step_definitions/steps.rb:4
      NOT MATCHED BY ANY STEPS
    
    4 scenarios (4 skipped)
    11 steps (11 skipped)
    
features/docs/formatters/usage_formatter.feature:58

Scenario: Run with --expand --format usage

  1. When I run `cucumber -x -f usage --dry-run`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    -----------
    
    /A/       # features/step_definitions/steps.rb:1
      Given A # features/f.feature:3
      Given A # features/f.feature:12
      Given A # features/f.feature:14
    /B/       # features/step_definitions/steps.rb:2
      Given B # features/f.feature:5
      And B   # features/f.feature:11
      And B   # features/f.feature:12
    /C/       # features/step_definitions/steps.rb:3
      Given C # features/f.feature:11
      Given C # features/f.feature:15
    /D/       # features/step_definitions/steps.rb:4
      NOT MATCHED BY ANY STEPS
    
    4 scenarios (4 skipped)
    11 steps (11 skipped)
    
features/docs/formatters/usage_formatter.feature:83

Scenario: Run with --format stepdefs

  1. When I run `cucumber -f stepdefs --dry-run`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    -----------
    
    /A/   # features/step_definitions/steps.rb:1
    /B/   # features/step_definitions/steps.rb:2
    /C/   # features/step_definitions/steps.rb:3
    /D/   # features/step_definitions/steps.rb:4
      NOT MATCHED BY ANY STEPS
    
    4 scenarios (4 skipped)
    11 steps (11 skipped)
    

Feature: Getting started


To get started, just open a command prompt in an empty directory and run
`cucumber`. You'll be prompted for what to do next.

@spawnfeatures/docs/getting_started.feature:7

Scenario: Run Cucumber in an empty directory

  1. Given a directory without standard Cucumber project directory structure
    features/lib/step_definitions/cucumber_steps.rb:1
  2. When I run `cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    No such file or directory - features. You can use `cucumber --init` to get started.
features/docs/getting_started.feature:15

Scenario: Accidentally run Cucumber in a folder with Ruby files in it.

  1. Given a directory without standard Cucumber project directory structure
    features/lib/step_definitions/cucumber_steps.rb:1
  2. And a file named "should_not_load.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    puts 'this will not be shown'
  3. When I run `cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then the exit status should be 2
    aruba-0.6.2/lib/aruba/cucumber.rb:197
  5. And the output should not contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:160
    this will not be shown
    

Feature: Background


Often you find that several scenarios in the same feature start with
a common context.

Cucumber provides a mechanism for this, by providing a `Background` keyword
where you can specify steps that should be run before each scenario in the
feature. Typically these will be `Given` steps, but you can use any steps
that you need to.

**Hint:** if you find that some of the scenarios don't fit the background,
consider splitting them into a separate feature.

Background

  1. Given a file named "features/passing_background.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Passing background sample
    
      Background:
        Given '10' cukes
    
      Scenario: passing background
        Then I should have '10' cukes    
    
      Scenario: another passing background
        Then I should have '10' cukes
  2. And a file named "features/scenario_outline_passing_background.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Passing background with scenario outlines sample
    
      Background:
        Given '10' cukes
    
      Scenario Outline: passing background
        Then I should have '<count>' cukes
        Examples:
          |count|
          | 10  |
    
      Scenario Outline: another passing background
        Then I should have '<count>' cukes
        Examples:
          |count|
          | 10  |
  3. And a file named "features/background_tagged_before_on_outline.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    @background_tagged_before_on_outline
    Feature: Background tagged Before on Outline
    
      Background: 
        Given this step passes
    
      Scenario Outline: passing background
        Then I should have '<count>' cukes
    
        Examples: 
          | count |
          | 888   |
  4. And a file named "features/failing_background.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Failing background sample
    
      Background:
        Given this step raises an error
        And '10' cukes
    
      Scenario: failing background
        Then I should have '10' cukes
    
      Scenario: another failing background
        Then I should have '10' cukes
  5. And a file named "features/scenario_outline_failing_background.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Failing background with scenario outlines sample
    
      Background:
        Given this step raises an error
    
      Scenario Outline: failing background
        Then I should have '<count>' cukes
        Examples:
          |count|
          | 10  |
    
      Scenario Outline: another failing background
        Then I should have '<count>' cukes
        Examples:
          |count|
          | 10  |
  6. And a file named "features/pending_background.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Pending background sample
    
      Background:
        Given this step is pending
    
      Scenario: pending background
        Then I should have '10' cukes
    
      Scenario: another pending background
        Then I should have '10' cukes
  7. And a file named "features/failing_background_after_success.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Failing background after previously successful background sample
    
      Background:
        Given this step passes
        And '10' global cukes
    
      Scenario: passing background
        Then I should have '10' global cukes
    
      Scenario: failing background
        Then I should have '10' global cukes
  8. And a file named "features/failing_background_after_success_outline.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Failing background after previously successful background sample
    
      Background:
        Given this step passes
        And '10' global cukes
    
      Scenario Outline: passing background
        Then I should have '<count>' global cukes
    
        Examples: 
          | count |
          | 10    |
    
      Scenario Outline: failing background
        Then I should have '<count>' global cukes
    
        Examples: 
          | count |
          | 10    |
    
  9. And a file named "features/multiline_args_background.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Passing background with multiline args
    
      Background:
        Given table
          |a|b|
          |c|d|
        And multiline string
          """
          I'm a cucumber and I'm okay. 
          I sleep all night and I test all day
          """
    
      Scenario: passing background
        Then the table should be
          |a|b|
          |c|d|
        Then the multiline string should be
          """
          I'm a cucumber and I'm okay. 
          I sleep all night and I test all day
          """
    
      Scenario: another passing background
        Then the table should be
          |a|b|
          |c|d|
        Then the multiline string should be
          """
          I'm a cucumber and I'm okay. 
          I sleep all night and I test all day
          """
  10. And the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  11. And a file named "features/step_definitions/cuke_steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given /^'(.+)' cukes$/ do |cukes| x=1
      raise "We already have #{@cukes} cukes!" if @cukes
      @cukes = cukes
    end
    
    Given /^'(.+)' global cukes$/ do |cukes| x=1
      $scenario_runs ||= 0
      raise 'FAIL' if $scenario_runs >= 1
      $cukes = cukes
      $scenario_runs += 1
    end
    
    Then /^I should have '(.+)' global cukes$/ do |cukes| x=1
      expect($cukes).to eq cukes
    end
    
    Then /^I should have '(.+)' cukes$/ do |cukes| x=1
      expect(@cukes).to eq cukes
    end
    
    Before('@background_tagged_before_on_outline') do
      @cukes = '888'
    end
    
    After('@background_tagged_before_on_outline') do
      expect(@cukes).to eq '888'
    end
features/docs/gherkin/background.feature:211

Scenario: run a specific scenario with a background

  1. When I run `cucumber -q features/passing_background.feature:9`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Passing background sample
    
      Background: 
        Given '10' cukes
    
      Scenario: another passing background
        Then I should have '10' cukes
    
    1 scenario (1 passed)
    2 steps (2 passed)
    
features/docs/gherkin/background.feature:228

Scenario: run a feature with a background that passes

  1. When I run `cucumber -q features/passing_background.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Passing background sample
    
      Background: 
        Given '10' cukes
    
      Scenario: passing background
        Then I should have '10' cukes
    
      Scenario: another passing background
        Then I should have '10' cukes
    
    2 scenarios (2 passed)
    4 steps (4 passed)
    
features/docs/gherkin/background.feature:248

Scenario: run a feature with scenario outlines that has a background that passes

  1. When I run `cucumber -q features/scenario_outline_passing_background.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Passing background with scenario outlines sample
    
      Background: 
        Given '10' cukes
    
      Scenario Outline: passing background
        Then I should have '<count>' cukes
    
        Examples: 
          | count |
          | 10    |
    
      Scenario Outline: another passing background
        Then I should have '<count>' cukes
    
        Examples: 
          | count |
          | 10    |
    
    2 scenarios (2 passed)
    4 steps (4 passed)
    
features/docs/gherkin/background.feature:276

Scenario: run a feature with scenario outlines that has a background that passes

  1. When I run `cucumber -q features/background_tagged_before_on_outline.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    @background_tagged_before_on_outline
    Feature: Background tagged Before on Outline
    
      Background: 
        Given this step passes
    
      Scenario Outline: passing background
        Then I should have '<count>' cukes
    
        Examples: 
          | count |
          | 888   |
    
    1 scenario (1 passed)
    2 steps (2 passed)
    
@spawnfeatures/docs/gherkin/background.feature:299

Scenario: run a feature with a background that fails

  1. When I run `cucumber -q features/failing_background.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Failing background sample
    
      Background: 
        Given this step raises an error
          error (RuntimeError)
          ./features/step_definitions/steps.rb:2:in `/^this step raises an error$/'
          features/failing_background.feature:4:in `Given this step raises an error'
        And '10' cukes
    
      Scenario: failing background
        Then I should have '10' cukes
    
      Scenario: another failing background
        Then I should have '10' cukes
    
    Failing Scenarios:
    cucumber features/failing_background.feature:7
    cucumber features/failing_background.feature:10
    
    2 scenarios (2 failed)
    6 steps (2 failed, 4 skipped)
    
@spawnfeatures/docs/gherkin/background.feature:328

Scenario: run a feature with scenario outlines that has a background that fails

  1. When I run `cucumber -q features/scenario_outline_failing_background.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Failing background with scenario outlines sample
    
      Background: 
        Given this step raises an error
          error (RuntimeError)
          ./features/step_definitions/steps.rb:2:in `/^this step raises an error$/'
          features/scenario_outline_failing_background.feature:4:in `Given this step raises an error'
    
      Scenario Outline: failing background
        Then I should have '<count>' cukes
    
        Examples: 
          | count |
          | 10    |
    
      Scenario Outline: another failing background
        Then I should have '<count>' cukes
    
        Examples: 
          | count |
          | 10    |
    
    Failing Scenarios:
    cucumber features/scenario_outline_failing_background.feature:10
    cucumber features/scenario_outline_failing_background.feature:16
    
    2 scenarios (2 failed)
    4 steps (2 failed, 2 skipped)
    
features/docs/gherkin/background.feature:363

Scenario: run a feature with a background that is pending

  1. When I run `cucumber -q features/pending_background.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Pending background sample
    
      Background: 
        Given this step is pending
          TODO (Cucumber::Pending)
          ./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
          features/pending_background.feature:4:in `Given this step is pending'
    
      Scenario: pending background
        Then I should have '10' cukes
    
      Scenario: another pending background
        Then I should have '10' cukes
    
    2 scenarios (2 pending)
    4 steps (2 skipped, 2 pending)
    
@spawnfeatures/docs/gherkin/background.feature:387

Scenario: background passes with first scenario but fails with second

  1. When I run `cucumber -q features/failing_background_after_success.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Failing background after previously successful background sample
    
      Background: 
        Given this step passes
        And '10' global cukes
    
      Scenario: passing background
        Then I should have '10' global cukes
    
      Scenario: failing background
        And '10' global cukes
          FAIL (RuntimeError)
          ./features/step_definitions/cuke_steps.rb:8:in `/^'(.+)' global cukes$/'
          features/failing_background_after_success.feature:5:in `And '10' global cukes'
        Then I should have '10' global cukes
    
    Failing Scenarios:
    cucumber features/failing_background_after_success.feature:10
    
    2 scenarios (1 failed, 1 passed)
    6 steps (1 failed, 1 skipped, 4 passed)
    
@spawnfeatures/docs/gherkin/background.feature:416

Scenario: background passes with first outline scenario but fails with second

  1. When I run `cucumber -q features/failing_background_after_success_outline.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Failing background after previously successful background sample
    
      Background: 
        Given this step passes
        And '10' global cukes
    
      Scenario Outline: passing background
        Then I should have '<count>' global cukes
    
        Examples: 
          | count |
          | 10    |
    
      Scenario Outline: failing background
        Then I should have '<count>' global cukes
    
        Examples: 
          | count |
          | 10    |
          FAIL (RuntimeError)
          ./features/step_definitions/cuke_steps.rb:8:in `/^'(.+)' global cukes$/'
          features/failing_background_after_success_outline.feature:5:in `And '10' global cukes'
    
    Failing Scenarios:
    cucumber features/failing_background_after_success_outline.feature:19
    
    2 scenarios (1 failed, 1 passed)
    6 steps (1 failed, 1 skipped, 4 passed)
    
@spawnfeatures/docs/gherkin/background.feature:452

Scenario: background passes with first outline scenario but fails with second (--expand)

  1. When I run `cucumber -x -q features/failing_background_after_success_outline.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Failing background after previously successful background sample
    
      Background: 
        Given this step passes
        And '10' global cukes
    
      Scenario Outline: passing background
        Then I should have '<count>' global cukes
    
        Examples: 
    
          Scenario: | 10 |
            Then I should have '10' global cukes
    
      Scenario Outline: failing background
        Then I should have '<count>' global cukes
    
        Examples: 
    
          Scenario: | 10 |
            And '10' global cukes
          FAIL (RuntimeError)
          ./features/step_definitions/cuke_steps.rb:8:in `/^'(.+)' global cukes$/'
          features/failing_background_after_success_outline.feature:5:in `And '10' global cukes'
            Then I should have '10' global cukes
    
    Failing Scenarios:
    cucumber features/failing_background_after_success_outline.feature:19
    
    2 scenarios (1 failed, 1 passed)
    6 steps (1 failed, 1 skipped, 4 passed)
    
features/docs/gherkin/background.feature:490

Scenario: background with multline args

  1. Given a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given /^table$/ do |table| x=1
      @table = table
    end
    
    Given /^multiline string$/ do |string| x=1
      @multiline = string
    end
    
    Then /^the table should be$/ do |table| x=1
      expect(@table.raw).to eq table.raw
    end
    
    Then /^the multiline string should be$/ do |string| x=1
      expect(@multiline).to eq string
    end
  2. When I run `cucumber -q features/multiline_args_background.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: Passing background with multiline args
    
      Background: 
        Given table
          | a | b |
          | c | d |
        And multiline string
          """
          I'm a cucumber and I'm okay. 
          I sleep all night and I test all day
          """
    
      Scenario: passing background
        Then the table should be
          | a | b |
          | c | d |
        Then the multiline string should be
          """
          I'm a cucumber and I'm okay. 
          I sleep all night and I test all day
          """
    
      Scenario: another passing background
        Then the table should be
          | a | b |
          | c | d |
        Then the multiline string should be
          """
          I'm a cucumber and I'm okay. 
          I sleep all night and I test all day
          """
    
    2 scenarios (2 passed)
    8 steps (8 passed)
    

Feature: Doc strings


If you need to specify information in a scenario that won't fit on a single line,
you can use a DocString.

A DocString follows a step, and starts and ends with three double quotes, like this:

```gherkin
When I ask to reset my password
Then I should receive an email with:
"""
Dear bozo,

Please click this link to reset your password
"""
```

It's possible to annotate the DocString with the type of content it contains. This is used by
formatting tools like http://relishapp.com which will render the contents of the DocString
appropriately. You specify the content type after the triple quote, like this:

```gherkin
Given there is some Ruby code:
"""ruby
puts "hello world"
"""
```

You can read the content type from the argument passed into your step definition, as shown
in the example below.

features/docs/gherkin/doc_strings.feature:32

Scenario: Plain text Docstring

  1. Given a scenario with a step that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:7
    Given I have a lot to say:
     """
     One
     Two
     Three
     """
  2. And a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /say/ do |text|
      puts text
    end
  3. When I run the feature with the progress formatter
    features/lib/step_definitions/cucumber_steps.rb:35
  4. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    One
    Two
    Three
features/docs/gherkin/doc_strings.feature:56

Scenario: DocString with interesting content type

  1. Given a scenario with a step that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:7
    Given I have some code for you:
     """ruby
     # hello
     """
  2. And a step definition that looks like this:
    features/lib/step_definitions/cucumber_steps.rb:31
    Given /code/ do |text|
      puts text.content_type
    end
  3. When I run the feature with the progress formatter
    features/lib/step_definitions/cucumber_steps.rb:35
  4. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    ruby

Feature: Scenario outlines --expand option


In order to make it easier to write certain editor plugins and also
for some people to understand scenarios, Cucumber will expand examples
in outlines if you add the `--expand` option when running them.

features/docs/gherkin/expand_option_for_outlines.feature:7

Scenario:

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario Outline:
        Given the secret code is <code>
        When I guess <guess>
        Then I am <verdict>
    
      Examples:
        | code | guess | verdict |
        | blue | blue  | right   |
        | red  | blue  | wrong   |
  2. When I run `cucumber -i -q --expand`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  4. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: 
    
      Scenario Outline: 
        Given the secret code is <code>
        When I guess <guess>
        Then I am <verdict>
    
        Examples: 
    
          Scenario: | blue | blue | right |
            Given the secret code is blue
            When I guess blue
            Then I am right
    
          Scenario: | red | blue | wrong |
            Given the secret code is red
            When I guess blue
            Then I am wrong
    
    2 scenarios (2 undefined)
    6 steps (6 undefined)

Feature: Choosing the language from the feature file header


In order to simplify command line and settings in IDEs, Cucumber picks
up the parser language from a `# language` comment at the beginning of
any feature file. See the examples below for the exact syntax.

features/docs/gherkin/language_from_header.feature:7

Scenario: LOLCAT

  1. Given a file named "features/lolcat.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    # language: en-lol
    OH HAI: STUFFING
      B4: HUNGRY
        I CAN HAZ EMPTY BELLY
      MISHUN: CUKES
        DEN KTHXBAI
  2. When I run `cucumber -i features/lolcat.feature -q`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    # language: en-lol
    OH HAI: STUFFING
    
      B4: HUNGRY
        I CAN HAZ EMPTY BELLY
    
      MISHUN: CUKES
        DEN KTHXBAI
    
    1 scenario (1 undefined)
    2 steps (2 undefined)
    
@needs-many-fonts

Feature: Language help


It's possible to ask cucumber which keywords are used for any
particular language by running:

`cucumber --i18n <language code> help`

This will print a table showing all the different words we use for
that language, to allow you to easily write features in any language
you choose.

features/docs/gherkin/language_help.feature:13

Scenario: Get help for Portuguese language

  1. When I run `cucumber --i18n pt help`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
          | feature          | "Funcionalidade", "Característica", "Caracteristica"                                         |
          | background       | "Contexto", "Cenário de Fundo", "Cenario de Fundo", "Fundo"                                  |
          | scenario         | "Cenário", "Cenario"                                                                         |
          | scenario_outline | "Esquema do Cenário", "Esquema do Cenario", "Delineação do Cenário", "Delineacao do Cenario" |
          | examples         | "Exemplos", "Cenários", "Cenarios"                                                           |
          | given            | "* ", "Dado ", "Dada ", "Dados ", "Dadas "                                                   |
          | when             | "* ", "Quando "                                                                              |
          | then             | "* ", "Então ", "Entao "                                                                     |
          | and              | "* ", "E "                                                                                   |
          | but              | "* ", "Mas "                                                                                 |
          | given (code)     | "Dado", "Dada", "Dados", "Dadas"                                                             |
          | when (code)      | "Quando"                                                                                     |
          | then (code)      | "Então", "Entao"                                                                             |
          | and (code)       | "E"                                                                                          |
          | but (code)       | "Mas"                                                                                        |
    
features/docs/gherkin/language_help.feature:35

Scenario: List languages

  1. When I run `cucumber --i18n help`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then cucumber lists all the supported languages
    features/lib/step_definitions/language_steps.rb:3
@spawn

Feature: Scenario outlines


Copying and pasting scenarios to use different values quickly
becomes tedious and repetitive. Scenario outlines allow us to more
concisely express these examples through the use of a template with
placeholders, using Scenario Outline, Examples with tables and < >
delimited parameters.

The Scenario Outline steps provide a template which is never directly
run. A Scenario Outline is run once for each row in the Examples section
beneath it (not counting the first row).

The way this works is via placeholders. Placeholders must be contained
within < > in the Scenario Outline's steps - see the examples below.

**IMPORTANT:** Your step definitions will never have to match a
placeholder. They will need to match the values that will replace the
placeholder.

Background

  1. Given a file named "features/outline_sample.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Outline Sample
    
      Scenario: I have no steps
    
      Scenario Outline: Test state
        Given <state> without a table
        Given <other_state> without a table
      Examples: Rainbow colours
        | state    | other_state |
        | missing  | passing     |
        | passing  | passing     |
        | failing  | passing     |
    Examples:Only passing
        | state    | other_state |
        | passing  | passing     |
  2. And a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given(/^passing without a table$/) { }
    Given(/^failing without a table$/) { raise RuntimeError }
features/docs/gherkin/outlines.feature:46

Scenario: Run scenario outline with filtering on outline name

  1. When I run `cucumber -q features/outline_sample.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Outline Sample
    
      Scenario: I have no steps
    
      Scenario Outline: Test state
        Given <state> without a table
        Given <other_state> without a table
    
        Examples: Rainbow colours
          | state   | other_state |
          | missing | passing     |
          | passing | passing     |
          | failing | passing     |
          RuntimeError (RuntimeError)
          ./features/step_definitions/steps.rb:2:in `/^failing without a table$/'
          features/outline_sample.feature:12:in `Given failing without a table'
          features/outline_sample.feature:6:in `Given <state> without a table'
    
        Examples: Only passing
          | state   | other_state |
          | passing | passing     |
    
    Failing Scenarios:
    cucumber features/outline_sample.feature:12
    
    5 scenarios (1 failed, 1 undefined, 3 passed)
    8 steps (1 failed, 2 skipped, 1 undefined, 4 passed)
features/docs/gherkin/outlines.feature:79

Scenario: Run scenario outline steps only

  1. When I run `cucumber -q features/outline_sample.feature:7`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Outline Sample
    
      Scenario Outline: Test state
        Given <state> without a table
        Given <other_state> without a table
    
        Examples: Rainbow colours
          | state   | other_state |
          | missing | passing     |
          | passing | passing     |
          | failing | passing     |
          RuntimeError (RuntimeError)
          ./features/step_definitions/steps.rb:2:in `/^failing without a table$/'
          features/outline_sample.feature:12:in `Given failing without a table'
          features/outline_sample.feature:6:in `Given <state> without a table'
    
        Examples: Only passing
          | state   | other_state |
          | passing | passing     |
    
    Failing Scenarios:
    cucumber features/outline_sample.feature:12
    
    4 scenarios (1 failed, 1 undefined, 2 passed)
    8 steps (1 failed, 2 skipped, 1 undefined, 4 passed)
    
features/docs/gherkin/outlines.feature:111

Scenario: Run single failing scenario outline table row

  1. When I run `cucumber -q features/outline_sample.feature:12`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Outline Sample
    
      Scenario Outline: Test state
        Given <state> without a table
        Given <other_state> without a table
    
        Examples: Rainbow colours
          | state   | other_state |
          | failing | passing     |
          RuntimeError (RuntimeError)
          ./features/step_definitions/steps.rb:2:in `/^failing without a table$/'
          features/outline_sample.feature:12:in `Given failing without a table'
          features/outline_sample.feature:6:in `Given <state> without a table'
    
    Failing Scenarios:
    cucumber features/outline_sample.feature:12
    
    1 scenario (1 failed)
    2 steps (1 failed, 1 skipped)
    
features/docs/gherkin/outlines.feature:137

Scenario: Run all with progress formatter

  1. When I run `cucumber -q --format progress features/outline_sample.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    U-..F-..
    
    (::) failed steps (::)
    
    RuntimeError (RuntimeError)
    ./features/step_definitions/steps.rb:2:in `/^failing without a table$/'
    features/outline_sample.feature:12:in `Given failing without a table'
    features/outline_sample.feature:6:in `Given <state> without a table'
    
    Failing Scenarios:
    cucumber features/outline_sample.feature:12
    
    5 scenarios (1 failed, 1 undefined, 3 passed)
    8 steps (1 failed, 2 skipped, 1 undefined, 4 passed)
    
@spawn

Feature: Unicode in tables


You are free to use unicode in your tables: we've taken care to
ensure that the tables are properly aligned so that your output is as
readable as possible.

features/docs/gherkin/unicode_table.feature:8

Scenario:

  1. Given a file named "features/unicode.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Featuring unicode
    
      Scenario: table with unicode
        Given passing
          | Brüno | abc |
          | Bruno | æøå |
  2. When I run `cucumber -q --dry-run features/unicode.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Featuring unicode
    
      Scenario: table with unicode
        Given passing
          | Brüno | abc |
          | Bruno | æøå |
    
    1 scenario (1 undefined)
    1 step (1 undefined)
    

Feature: Using descriptions to give features context


When writing your feature files its very helpful to use description
text at the beginning of the feature file, to write a preamble to the
feature describing clearly exactly what the feature does.

You can also write descriptions attached to individual scenarios - see
the examples below for how this can be used.

It's possible to have your descriptions run over more than one line,
and you can have blank lines too. As long as you don't start a line
with a Given, When, Then, Background:, Scenario: or similar, you're
fine: otherwise Gherkin will start to pay attention.

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
features/docs/gherkin/using_descriptions.feature:18

Scenario: Everything with a description

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: descriptions everywhere
    
      We can put a useful description here of the feature, which can
      span multiple lines.
    
      Background:
    
        We can also put in descriptions showing what the background is
        doing.
    
        Given this step passes
    
      Scenario: I'm a scenario with a description
    
        You can also put descriptions in front of individual scenarios.
    
        Given this step passes
    
      Scenario Outline: I'm a scenario outline with a description
    
        Scenario outlines can have descriptions.
    
        Given this step <state>
        Examples: Examples
    
          Specific examples for an outline are allowed to have
          descriptions, too.
    
          |  state |
          | passes |
  2. When I run `cucumber -q`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  4. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: descriptions everywhere
      
      We can put a useful description here of the feature, which can
      span multiple lines.
    
      Background: 
        
        We can also put in descriptions showing what the background is
        doing.
        Given this step passes
    
      Scenario: I'm a scenario with a description
        
        You can also put descriptions in front of individual scenarios.
        Given this step passes
    
      Scenario Outline: I'm a scenario outline with a description
        
        Scenario outlines can have descriptions.
        Given this step <state>
    
        Examples: Examples
          
          Specific examples for an outline are allowed to have
          descriptions, too.
          | state  |
          | passes |
    
    2 scenarios (2 passed)
    4 steps (4 passed)
    

Feature: Using star notation instead of Given/When/Then


Cucumber supports the star notation when writing features: instead of
using Given/When/Then, you can simply use a star rather like you would
use a bullet point.

When you run the feature for the first time, you still get a nice
message showing you the code snippet you need to use to implement the
step.

features/docs/gherkin/using_star_notation.feature:11

Scenario: Use some *

  1. Given a file named "features/f.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Star-notation feature
      Scenario: S
        * I have some cukes
  2. When I run `cucumber features/f.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  4. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Star-notation feature
    
      Scenario: S           # features/f.feature:2
        * I have some cukes # features/f.feature:3
    
    1 scenario (1 undefined)
    1 step (1 undefined)
  5. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    You can implement step definitions for undefined steps with these snippets:
    
    Given(/^I have some cukes$/) do
      pending # Write code here that turns the phrase above into concrete actions
    end
# language: no
# encoding: iso-8859-1

Egenskap: Alle bruker ikke UTF-8

features/docs/iso-8859-1.feature:4

Scenario: Dette bør gå bra

  1. Når jeg drikker en "øl"
    features/lib/step_definitions/iso-8859-1_steps.rb:6
  2. skal de andre si "skål"
    features/lib/step_definitions/iso-8859-1_steps.rb:10

Feature: Post Configuration Hook [#423]


In order to extend Cucumber
As a developer
I want to manipulate the Cucumber configuration after it has been created

# Fails on Travis under JRuby
@spawn @wip-jrubyfeatures/docs/post_configuration_hook.feature:10

Scenario: Using options directly gets a deprecation warning

  1. Given a file named "features/support/env.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    AfterConfiguration do |config|
      config.options[:blah]
    end
  2. When I run `cucumber features`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the stderr should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:234
    Deprecated
features/docs/post_configuration_hook.feature:23

Scenario: Changing the output format

  1. Given a file named "features/support/env.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    AfterConfiguration do |config|
      config.formats << ['html', config.out_stream]
    end
  2. When I run `cucumber features`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  4. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    html
features/docs/post_configuration_hook.feature:37

Scenario: feature directories read from configuration

  1. Given a file named "features/support/env.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    AfterConfiguration do |config|
      config.out_stream << "AfterConfiguration hook read feature directories: #{config.feature_dirs.join(', ')}"
    end
  2. When I run `cucumber features`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  4. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    AfterConfiguration hook read feature directories: features

Feature: Profiles


In order to save time and prevent carpal tunnel syndrome
Cucumber users can save and reuse commonly used cucumber flags in a 'cucumber.yml' file.
These named arguments are called profiles and the yml file should be in the root of your project.
Any cucumber argument is valid in a profile. To see all the available flags type 'cucumber --help'
For more information about profiles please see the wiki:
http://wiki.github.com/cucumber/cucumber/cucumber.yml

Background Basic App

  1. Given a file named "features/sample.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
      Scenario: this is a test
        Given this step raises an error
  2. And an empty file named "features/support/env.rb"
    aruba-0.6.2/lib/aruba/cucumber.rb:42
  3. And an empty file named "features/support/super_env.rb"
    aruba-0.6.2/lib/aruba/cucumber.rb:42
  4. And the following profiles are defined:
    features/lib/step_definitions/profile_steps.rb:1
    default: features/sample.feature --require features/support/env.rb -v
    super: features/sample.feature --require features/support/super_env.rb -v
features/docs/profiles.feature:25

Scenario: Explicitly defining a profile to run

  1. When I run `cucumber features/sample.feature --profile super`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Using the super profile...
  3. And exactly these files should be loaded: features/support/super_env.rb
    features/lib/step_definitions/profile_steps.rb:9
features/docs/profiles.feature:33

Scenario: Explicitly defining a profile defined in an ERB formatted file

  1. Given the following profiles are defined:
    features/lib/step_definitions/profile_steps.rb:1
    <% requires = "--require features/support/super_env.rb" %>
    super: <%= "features/sample.feature #{requires} -v" %>
  2. When I run `cucumber features/sample.feature --profile super`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Using the super profile...
  4. And exactly these files should be loaded: features/support/super_env.rb
    features/lib/step_definitions/profile_steps.rb:9
features/docs/profiles.feature:46

Scenario: Defining multiple profiles to run

  1. When I run `cucumber features/sample.feature --profile default --profile super`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Using the default and super profiles...
  3. And exactly these files should be loaded: features/support/env.rb, features/support/super_env.rb
    features/lib/step_definitions/profile_steps.rb:9
features/docs/profiles.feature:54

Scenario: Arguments passed in but no profile specified

  1. When I run `cucumber -v`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the default profile should be used
    features/lib/step_definitions/profile_steps.rb:5
  3. And exactly these files should be loaded: features/support/env.rb
    features/lib/step_definitions/profile_steps.rb:9
features/docs/profiles.feature:59

Scenario: Trying to use a missing profile

  1. When I run `cucumber -p foo`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the stderr should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:234
    Could not find profile: 'foo'
    
    Defined profiles in cucumber.yml:
      * default
      * super
    
features/docs/profiles.feature:71

Scenario Outline: Disabling the default profile

  1. When I run `cucumber -v features/ <flag>`
    features/docs/profiles.feature:72
  2. Then the output should contain:
    features/docs/profiles.feature:73
    Disabling profiles...
  3. And exactly these files should be loaded: features/support/env.rb, features/support/super_env.rb
    features/docs/profiles.feature:77

Examples

flag
-P
--no-profile
features/docs/profiles.feature:84

Scenario: Overriding the profile's features to run

  1. Given a file named "features/another.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Just this one should be ran
  2. When I run `cucumber -p default features/another.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then exactly these features should be ran: features/another.feature
    features/lib/step_definitions/profile_steps.rb:13
features/docs/profiles.feature:92

Scenario: Overriding the profile's formatter You will most likely want to define a formatter in your default formatter. However, you often want to run your features with a different formatter yet still use the other the other arguments in the profile. Cucumber will allow you to do this by giving precedence to the formatter specified on the command line and override the one in the profile.

  1. Given the following profiles are defined:
    features/lib/step_definitions/profile_steps.rb:1
    default: features/sample.feature --require features/support/env.rb -v --format profile
  2. When I run `cucumber features --format pretty`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Feature: Sample
features/docs/profiles.feature:109

Scenario Outline: Showing profiles when listing failing scenarios

  1. Given the standard step definitions
    features/docs/profiles.feature:110
  2. When I run `cucumber -q -p super -p default -f <format> features/sample.feature --require features/step_definitions/steps.rb`
    features/docs/profiles.feature:111
  3. Then it should fail with:
    features/docs/profiles.feature:112
    cucumber -p super features/sample.feature:2

Examples

format
pretty
progress
@spawn

Feature: Rake task

In order to ease the development process
As a developer and CI server administrator
Cucumber features should be executable via Rake

Background

  1. And a file named "features/missing_step_definitions.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
    
      Scenario: Wanted
        Given I want to run this
    
      Scenario: Unwanted
        Given I don't want this ran
features/docs/rake_task.feature:19

Scenario: rake task with a defined profile

  1. Given the following profile is defined:
    features/lib/step_definitions/profile_steps.rb:1
    foo: --quiet --no-color features/missing_step_definitions.feature:3
  2. And a file named "Rakefile" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    require 'cucumber/rake/task'
    
    Cucumber::Rake::Task.new do |t|
      t.profile = "foo"
    end
  3. When I run `rake cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Sample
    
      Scenario: Wanted
        Given I want to run this
    
    1 scenario (1 undefined)
    1 step (1 undefined)
features/docs/rake_task.feature:44

Scenario: rake task without a profile

  1. Given a file named "Rakefile" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    require 'cucumber/rake/task'
    
    Cucumber::Rake::Task.new do |t|
      t.cucumber_opts = %w{--quiet --no-color}
    end
  2. When I run `rake cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Sample
    
      Scenario: Wanted
        Given I want to run this
    
      Scenario: Unwanted
        Given I don't want this ran
    
    2 scenarios (2 undefined)
    2 steps (2 undefined)
features/docs/rake_task.feature:68

Scenario: rake task with a defined profile and cucumber_opts

  1. Given the following profile is defined:
    features/lib/step_definitions/profile_steps.rb:1
    bar: ['features/missing_step_definitions.feature:3']
  2. And a file named "Rakefile" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    require 'cucumber/rake/task'
    
    Cucumber::Rake::Task.new do |t|
      t.profile = "bar"
      t.cucumber_opts = %w{--quiet --no-color}
    end
  3. When I run `rake cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Sample
    
      Scenario: Wanted
        Given I want to run this
    
    1 scenario (1 undefined)
    1 step (1 undefined)
features/docs/rake_task.feature:94

Scenario: respect requires

  1. Given an empty file named "features/support/env.rb"
    aruba-0.6.2/lib/aruba/cucumber.rb:42
  2. And an empty file named "features/support/dont_require_me.rb"
    aruba-0.6.2/lib/aruba/cucumber.rb:42
  3. And the following profile is defined:
    features/lib/step_definitions/profile_steps.rb:1
    no_bomb: features/missing_step_definitions.feature:3 --require features/support/env.rb --verbose
  4. And a file named "Rakefile" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    require 'cucumber/rake/task'
    
    Cucumber::Rake::Task.new do |t|
      t.profile = "no_bomb"
      t.cucumber_opts = %w{--quiet --no-color}
    end
  5. When I run `rake cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  6. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7
  7. And the output should not contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:160
      * features/support/dont_require_me.rb
features/docs/rake_task.feature:117

Scenario: feature files with spaces

  1. Given a file named "features/spaces are nasty.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: The futures green
    
      Scenario: Orange
        Given this is missing
  2. And a file named "Rakefile" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    require 'cucumber/rake/task'
    
    Cucumber::Rake::Task.new do |t|
      t.cucumber_opts = %w{--quiet --no-color}
    end
  3. When I run `rake cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: The futures green
    
      Scenario: Orange
        Given this is missing
    
@spawn

Feature: Raketask


In order to use cucumber's rake task
As a Cuker
I do not want to see rake's backtraces when it fails
Also I want to get zero exit status code on failures
And non-zero exit status code when it pases

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. Given a file named "features/passing_and_failing.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Sample
    
      Scenario: Passing
        Given this step passes
    
      Scenario: Failing
        Given this step raises an error
  3. Given a file named "Rakefile" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
      require 'cucumber/rake/task'
    
      SAMPLE_FEATURE_FILE = 'features/passing_and_failing.feature'
    
      Cucumber::Rake::Task.new(:pass) do |t|
        t.cucumber_opts = "#{SAMPLE_FEATURE_FILE}:3"
      end
    
      Cucumber::Rake::Task.new(:fail) do |t|
        t.cucumber_opts = "#{SAMPLE_FEATURE_FILE}:6"
      end
features/docs/raketask.feature:37

Scenario: Passing feature

  1. When I run `bundle exec rake pass`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the exit status should be 0
    aruba-0.6.2/lib/aruba/cucumber.rb:197
features/docs/raketask.feature:41

Scenario: Failing feature

  1. When I run `bundle exec rake fail`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the exit status should be 1
    aruba-0.6.2/lib/aruba/cucumber.rb:197
  3. But the output should not contain "rake aborted!"
    aruba-0.6.2/lib/aruba/cucumber.rb:152
@wire

Feature: ERB configuration


As a developer on server with multiple users
I want to be able to configure which port my wire server runs on
So that I can avoid port conflicts

Background

  1. Given a file named "features/wired.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: High strung
      Scenario: Wired
        Given we're all wired
    
features/docs/wire_protocol/erb_configuration.feature:17

Scenario: ERB is used in the wire file which references an environment variable that is not set

  1. Given a file named "features/step_definitions/server.wire" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    host: localhost
    port: <%= ENV['PORT'] || 12345 %>
  2. And there is a wire server running on port 12345 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[]]
  3. When I run `cucumber --dry-run --no-snippets -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    U
    
    1 scenario (1 undefined)
    1 step (1 undefined)
    
features/docs/wire_protocol/erb_configuration.feature:37

Scenario: ERB is used in the wire file which references an environment variable

  1. Given I have environment variable PORT set to "16816"
    features/lib/step_definitions/wire_steps.rb:16
  2. And a file named "features/step_definitions/server.wire" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    host: localhost
    port: <%= ENV['PORT'] || 12345 %>
  3. And there is a wire server running on port 16816 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[]]
  4. When I run `cucumber --dry-run --no-snippets -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    U
    
    1 scenario (1 undefined)
    1 step (1 undefined)
    
@wire

Feature: Handle unexpected response


When the server sends us back a message we don't understand, this is how Cucumber will behave.

Background

  1. Given a file named "features/wired.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: High strung
      Scenario: Wired
        Given we're all wired
    
  2. And a file named "features/step_definitions/some_remote_place.wire" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    host: localhost
    port: 54321
    
features/docs/wire_protocol/handle_unexpected_response.feature:21

Scenario: Unexpected response

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["begin_scenario"]
    ["yikes"]
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[]}]]
  2. When I run `cucumber -f pretty`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    undefined method `handle_yikes'
@wire

Feature: Invoke message


Assuming a StepMatch was returned for a given step name, when it's time to
invoke that step definition, Cucumber will send an invoke message.

The invoke message contains the ID of the step definition, as returned by
the wire server in response to the the step_matches call, along with the
arguments that were parsed from the step name during the same step_matches
call.

The wire server will normally reply one of the following:

* `success`
* `fail`
* `pending` - optionally takes a message argument

This isn't quite the whole story: see also table_diffing.feature

Background

  1. Given a file named "features/wired.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: High strung
      Scenario: Wired
        Given we're all wired
    
  2. And a file named "features/step_definitions/some_remote_place.wire" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    host: localhost
    port: 54321
    
@spawnfeatures/docs/wire_protocol/invoke_message.feature:37

Scenario: Invoke a step definition which is pending

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[]}]]
    ["begin_scenario"]
    ["success"]
    ["invoke",{"id":"1","args":[]}]
    ["pending", "I'll do it later"]
    ["end_scenario"]
    ["success"]
  2. When I run `cucumber -f pretty -q`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: High strung
    
      Scenario: Wired
        Given we're all wired
          I'll do it later (Cucumber::Pending)
          features/wired.feature:3:in `Given we're all wired'
    
    1 scenario (1 pending)
    1 step (1 pending)
    
features/docs/wire_protocol/invoke_message.feature:59

Scenario: Invoke a step definition which passes

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[]}]]
    ["begin_scenario"]
    ["success"]
    ["invoke",{"id":"1","args":[]}]
    ["success"]
    ["end_scenario"]
    ["success"]
  2. When I run `cucumber -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    .
    
    1 scenario (1 passed)
    1 step (1 passed)
    
@spawnfeatures/docs/wire_protocol/invoke_message.feature:77

Scenario: Invoke a step definition which fails If an invoked step definition fails, it can return details of the exception in the reply to invoke. This causes a Cucumber::WireSupport::WireException to be raised. Valid arguments are: - `message` (mandatory) - `exception` - `backtrace` See the specs for Cucumber::WireSupport::WireException for more details

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[]}]]
    ["begin_scenario"]
    ["success"]
    ["invoke",{"id":"1","args":[]}]
    ["fail",{"message":"The wires are down", "exception":"Some.Foreign.ExceptionType"}]
    ["end_scenario"]
    ["success"]
  2. When I run `cucumber -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  4. And it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    F
    
    (::) failed steps (::)
    
    The wires are down (Some.Foreign.ExceptionType from localhost:54321)
    features/wired.feature:3:in `Given we're all wired'
    
    Failing Scenarios:
    cucumber features/wired.feature:2 # Scenario: Wired
    
    1 scenario (1 failed)
    1 step (1 failed)
    
features/docs/wire_protocol/invoke_message.feature:116

Scenario: Invoke a step definition which takes string arguments (and passes) If the step definition at the end of the wire captures arguments, these are communicated back to Cucumber in the `step_matches` message. Cucumber expects these StepArguments to be returned in the StepMatch. The keys have the following meanings: - `val` - the value of the string captured for that argument from the step name passed in step_matches - `pos` - the position within the step name that the argument was matched (used for formatter highlighting) The argument values are then sent back by Cucumber in the `invoke` message.

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[{"val":"wired", "pos":10}]}]]
    ["begin_scenario"]
    ["success"]
    ["invoke",{"id":"1","args":["wired"]}]
    ["success"]
    ["end_scenario"]
    ["success"]
  2. When I run `cucumber -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  4. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    .
    
    1 scenario (1 passed)
    1 step (1 passed)
    
features/docs/wire_protocol/invoke_message.feature:148

Scenario: Invoke a step definition which takes regular and table arguments (and passes) If the step has a multiline table argument, it will be passed with the invoke message as an array of array of strings. In this scenario our step definition takes two arguments - one captures the "we're" and the other takes the table.

  1. Given a file named "features/wired_on_tables.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: High strung
      Scenario: Wired and more
        Given we're all:
          | wired |
          | high  |
          | happy |
  2. And there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all:"}]
    ["success",[{"id":"1", "args":[{"val":"we're", "pos":0}]}]]
    ["begin_scenario"]
    ["success"]
    ["invoke",{"id":"1","args":["we're",[["wired"],["high"],["happy"]]]}]
    ["success"]
    ["end_scenario"]
    ["success"]
  3. When I run `cucumber -f progress features/wired_on_tables.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  5. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    .
    
    1 scenario (1 passed)
    1 step (1 passed)
    
features/docs/wire_protocol/invoke_message.feature:182

Scenario: Invoke a scenario outline step

  1. Given a file named "features/wired_in_an_outline.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario Outline:
        Given we're all <arg>
    
        Examples:
          | arg   |
          | wired |
  2. And there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[]}]]
    ["begin_scenario"]
    ["success"]
    ["invoke",{"id":"1","args":[]}]
    ["success"]
    ["end_scenario"]
    ["success"]
  3. When I run `cucumber -f progress features/wired_in_an_outline.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  5. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    .
    
    1 scenario (1 passed)
    1 step (1 passed)
    
  6. And the wire server should have received the following messages:
    features/lib/step_definitions/wire_steps.rb:20
    step_matches
    begin_scenario
    invoke
    end_scenario
@wire

Feature: Snippets message


If a step doesn't match, Cucumber will ask the wire server to return a snippet of code for a
step definition.

Background

  1. Given a file named "features/wired.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: High strung
      Scenario: Wired
        Given we're all wired
    
  2. And a file named "features/step_definitions/some_remote_place.wire" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    host: localhost
    port: 54321
    
@spawnfeatures/docs/wire_protocol/snippets_message.feature:23

Scenario: Wire server returns snippets for a step that didn't match

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[]]
    ["snippet_text",{"step_keyword":"Given","multiline_arg_class":"","step_name":"we're all wired"}]
    ["success","foo() bar; baz"]
    ["begin_scenario"]
    ["success"]
    ["end_scenario"]
    ["success"]
  2. When I run `cucumber -f pretty`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  4. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: High strung
    
      Scenario: Wired         # features/wired.feature:2
        Given we're all wired # features/wired.feature:3
    
    1 scenario (1 undefined)
    1 step (1 undefined)
  5. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    You can implement step definitions for undefined steps with these snippets:
    
    foo()
      bar;
    baz
    
@wire

Feature: Step matches message


When the features have been parsed, Cucumber will send a `step_matches`
message to ask the wire server if it can match a step name. This happens for
each of the steps in each of the features.

The wire server replies with an array of StepMatch objects.

When each StepMatch is returned, it contains the following data:

* `id` - identifier for the step definition to be used later when if it
needs to be invoked. The identifier can be any string value and
is simply used for the wire server's own reference.
* `args` - any argument values as captured by the wire end's own regular
expression (or other argument matching) process.

Background

  1. Given a file named "features/wired.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: High strung
      Scenario: Wired
        Given we're all wired
    
  2. And a file named "features/step_definitions/some_remote_place.wire" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    host: localhost
    port: 54321
    
features/docs/wire_protocol/step_matches_message.feature:33

Scenario: Dry run finds no step match

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[]]
  2. When I run `cucumber --dry-run --no-snippets -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    U
    
    1 scenario (1 undefined)
    1 step (1 undefined)
    
features/docs/wire_protocol/step_matches_message.feature:47

Scenario: Dry run finds a step match

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[]}]]
  2. When I run `cucumber --dry-run -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    -
    
    1 scenario (1 skipped)
    1 step (1 skipped)
    
features/docs/wire_protocol/step_matches_message.feature:61

Scenario: Step matches returns details about the remote step definition Optionally, the StepMatch can also contain a source reference, and a native regexp string which will be used by some formatters.

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[], "source":"MyApp.MyClass:123", "regexp":"we.*"}]]
  2. When I run `cucumber -f stepdefs --dry-run`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    -
    
    we.*   # MyApp.MyClass:123
    
    1 scenario (1 skipped)
    1 step (1 skipped)
    
  4. And the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
@wire

Feature: Wire protocol table diffing


In order to use the amazing functionality in the Cucumber table object
As a wire server
I want to be able to ask for a table diff during a step definition invocation

Background

  1. Given a file named "features/wired.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Hello
      Scenario: Wired
        Given we're all wired
    
  2. And a file named "features/step_definitions/some_remote_place.wire" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    host: localhost
    port: 54321
    
@spawnfeatures/docs/wire_protocol/table_diffing.feature:24

Scenario: Invoke a step definition tries to diff the table and fails

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[]}]]
    ["begin_scenario"]
    ["success"]
    ["invoke",{"id":"1","args":[]}]
    ["diff",[[["a","b"],["c","d"]],[["x","y"],["z","z"]]]]
    ["diff_failed"]
    ["fail",{"message":"Not same", "exception":"DifferentException", "backtrace":["a.cs:12","b.cs:34"]}]
    ["end_scenario"]
    ["success"]
  2. When I run `cucumber -f progress --backtrace`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  4. And it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    F
    
    (::) failed steps (::)
    
    Not same (DifferentException from localhost:54321)
    a.cs:12
    b.cs:34
    features/wired.feature:3:in `Given we're all wired'
    
    Failing Scenarios:
    cucumber features/wired.feature:2 # Scenario: Wired
    
    1 scenario (1 failed)
    1 step (1 failed)
    
features/docs/wire_protocol/table_diffing.feature:53

Scenario: Invoke a step definition tries to diff the table and passes

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[]}]]
    ["begin_scenario"]
    ["success"]
    ["invoke",{"id":"1","args":[]}]
    ["diff",[[["a"],["b"]],[["a"],["b"]]]]
    ["diff_ok"]
    ["success"]
    ["end_scenario"]
    ["success"]
  2. When I run `cucumber -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    .
    
    1 scenario (1 passed)
    1 step (1 passed)
    
@spawnfeatures/docs/wire_protocol/table_diffing.feature:72

Scenario: Invoke a step definition which successfully diffs a table but then fails

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[]}]]
    ["begin_scenario"]
    ["success"]
    ["invoke",{"id":"1","args":[]}]
    ["diff",[[["a"],["b"]],[["a"],["b"]]]]
    ["diff_ok"]
    ["fail",{"message":"I wanted things to be different for us"}]
    ["end_scenario"]
    ["success"]
  2. When I run `cucumber -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    F
    
    (::) failed steps (::)
    
    I wanted things to be different for us (Cucumber::WireSupport::WireException)
    features/wired.feature:3:in `Given we're all wired'
    
    Failing Scenarios:
    cucumber features/wired.feature:2 # Scenario: Wired
    
    1 scenario (1 failed)
    1 step (1 failed)
    
@spawnfeatures/docs/wire_protocol/table_diffing.feature:99

Scenario: Invoke a step definition which asks for an immediate diff that fails

  1. Given there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[]}]]
    ["begin_scenario"]
    ["success"]
    ["invoke",{"id":"1","args":[]}]
    ["diff!",[[["a"]],[["b"]]]]
    ["end_scenario"]
    ["success"]
  2. When I run `cucumber -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. And it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    F
    
    (::) failed steps (::)
    
    Tables were not identical:
    
      | (-) a | (+) b |
     (Cucumber::MultilineArgument::DataTable::Different)
    features/wired.feature:3:in `Given we're all wired'
    
    Failing Scenarios:
    cucumber features/wired.feature:2 # Scenario: Wired
    
    1 scenario (1 failed)
    1 step (1 failed)
    0m0.012s
    
@wire

Feature: Wire protocol tags


In order to use Before and After hooks in a wire server, we send tags with the
scenario in the begin_scenario and end_scenario messages

Background

  1. And a file named "features/step_definitions/some_remote_place.wire" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    host: localhost
    port: 54321
    
features/docs/wire_protocol/tags.feature:15

Scenario: Run a scenario

  1. Given a file named "features/wired.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
      @foo @bar
      Feature: Wired
      
        @baz
        Scenario: Everybody's Wired
          Given we're all wired
    
  2. And there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[]}]]
    ["begin_scenario", {"tags":["bar","baz","foo"]}]
    ["success"]
    ["invoke",{"id":"1","args":[]}]
    ["success"]
    ["end_scenario", {"tags":["bar","baz","foo"]}]
    ["success"]
  3. When I run `cucumber -f pretty -q`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  5. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    @foo @bar
    Feature: Wired
    
      @baz
      Scenario: Everybody's Wired
        Given we're all wired
    
    1 scenario (1 passed)
    1 step (1 passed)
    
features/docs/wire_protocol/tags.feature:48

Scenario: Run a scenario outline example

  1. Given a file named "features/wired.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
      @foo @bar
      Feature: Wired
      
        @baz
        Scenario Outline: Everybody's Wired
          Given we're all <something>
          
        Examples:
          | something |
          | wired     |
    
  2. And there is a wire server running on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[]}]]
    ["begin_scenario", {"tags":["bar","baz","foo"]}]
    ["success"]
    ["invoke",{"id":"1","args":[]}]
    ["success"]
    ["end_scenario", {"tags":["bar","baz","foo"]}]
    ["success"]
  3. When I run `cucumber -f pretty -q`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  5. And it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    @foo @bar
    Feature: Wired
    
      @baz
      Scenario Outline: Everybody's Wired
        Given we're all <something>
    
        Examples: 
          | something |
          | wired     |
    
    1 scenario (1 passed)
    1 step (1 passed)
    
@wire

Feature: Wire protocol timeouts


We don't want Cucumber to hang forever on a wire server that's not even there,
but equally we need to give the user the flexibility to allow step definitions
to take a while to execute, if that's what they need.

Background

  1. And a file named "features/wired.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Telegraphy
      Scenario: Wired
        Given we're all wired
    
features/docs/wire_protocol/timeouts.feature:17

Scenario: Try to talk to a server that's not there

  1. Given a file named "features/step_definitions/some_remote_place.wire" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    host: localhost
    port: 54321
    
  2. When I run `cucumber -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  3. Then the stderr should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:234
    Unable to contact the wire server at localhost:54321
@spawnfeatures/docs/wire_protocol/timeouts.feature:31

Scenario: Invoke a step definition that takes longer than its timeout

  1. Given a file named "features/step_definitions/some_remote_place.wire" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    host: localhost
    port: 54321
    timeout:
      invoke: 0.1
    
  2. And there is a wire server on port 54321 which understands the following protocol:
    features/lib/step_definitions/wire_steps.rb:1
    request
    response
    ["step_matches",{"name_to_match":"we're all wired"}]
    ["success",[{"id":"1", "args":[{"val":"wired", "pos":10}]}]]
    ["begin_scenario"]
    ["success"]
    ["invoke",{"id":"1","args":["wired"]}]
    ["success"]
    ["end_scenario"]
    ["success"]
  3. And the wire server takes 0.2 seconds to respond to the invoke message
    features/lib/step_definitions/wire_steps.rb:11
  4. When I run `cucumber -f pretty`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  6. And it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Telegraphy
    
      Scenario: Wired         # features/wired.feature:2
        Given we're all wired # Unknown
          Timed out calling wire server with message 'invoke' (Timeout::Error)
          features/wired.feature:3:in `Given we're all wired'
    
    Failing Scenarios:
    cucumber features/wired.feature:2 # Scenario: Wired
    
    1 scenario (1 failed)
    1 step (1 failed)
    
@spawn

Feature: Cucumber --work-in-progress switch

In order to ensure that feature scenarios do not pass until they are expected to
Developers should be able to run cucumber in a mode that
- will fail if any scenario passes completely
- will not fail otherwise

Background A passing and a pending feature

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. And a file named "features/wip.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: WIP
      @failing
      Scenario: Failing
        Given this step raises an error
    
      @undefined
      Scenario: Undefined
        Given this step is undefined
    
      @pending
      Scenario: Pending
        Given this step is pending
    
      @passing
      Scenario: Passing
        Given this step passes
  3. And a file named "features/passing_outline.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Not WIP
      Scenario Outline: Passing
        Given this step <what>
    
        Examples:
          | what   |
          | passes |
features/docs/work_in_progress.feature:40

Scenario: Pass with Failing Scenarios

  1. When I run `cucumber -q -w -t @failing features/wip.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the stderr should not contain anything
    aruba-0.6.2/lib/aruba/cucumber.rb:274
  3. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: WIP
    
      @failing
      Scenario: Failing
        Given this step raises an error
          error (RuntimeError)
          ./features/step_definitions/steps.rb:2:in `/^this step raises an error$/'
          features/wip.feature:4:in `Given this step raises an error'
    
    Failing Scenarios:
    cucumber features/wip.feature:3
    
    1 scenario (1 failed)
    1 step (1 failed)
  4. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    The --wip switch was used, so the failures were expected. All is good.
    
features/docs/work_in_progress.feature:66

Scenario: Pass with Undefined Scenarios

  1. When I run `cucumber -q -w -t @undefined features/wip.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: WIP
    
      @undefined
      Scenario: Undefined
        Given this step is undefined
    
    1 scenario (1 undefined)
    1 step (1 undefined)
  3. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    The --wip switch was used, so the failures were expected. All is good.
    
features/docs/work_in_progress.feature:85

Scenario: Pass with Undefined Scenarios

  1. When I run `cucumber -q -w -t @pending features/wip.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: WIP
    
      @pending
      Scenario: Pending
        Given this step is pending
          TODO (Cucumber::Pending)
          ./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
          features/wip.feature:12:in `Given this step is pending'
    
    1 scenario (1 pending)
    1 step (1 pending)
  3. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    The --wip switch was used, so the failures were expected. All is good.
    
features/docs/work_in_progress.feature:107

Scenario: Fail with Passing Scenarios

  1. When I run `cucumber -q -w -t @passing features/wip.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: WIP
    
      @passing
      Scenario: Passing
        Given this step passes
    
    1 scenario (1 passed)
    1 step (1 passed)
  3. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    The --wip switch was used, so I didn't expect anything to pass. These scenarios passed:
    (::) passed scenarios (::)
    
    features/wip.feature:15:in `Scenario: Passing'
    
    
features/docs/work_in_progress.feature:130

Scenario: Fail with Passing Scenario Outline

  1. When I run `cucumber -q -w features/passing_outline.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Not WIP
    
      Scenario Outline: Passing
        Given this step <what>
    
        Examples: 
          | what   |
          | passes |
    
    1 scenario (1 passed)
    1 step (1 passed)
  3. And the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    The --wip switch was used, so I didn't expect anything to pass. These scenarios passed:
    (::) passed scenarios (::)
    
    features/passing_outline.feature:7:in `Scenario Outline: Passing, Examples (#1)'
    
    

Feature: After Hooks


After hooks can be used to clean up any state you've altered during your
scenario, or to check the status of the scenario and act accordingly.

You can ask a scenario whether it has failed, for example.

Mind you, even if it hasn't failed yet, you can still make the scenario
fail if your After hook throws an error.

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
features/docs/writing_support_code/after_hooks.feature:14

Scenario Outline: Retreive the status of a scenario as a symbol

  1. Given a file named "features/support/debug_hook.rb" with:
    features/docs/writing_support_code/after_hooks.feature:15
    After do |scenario|
      puts scenario.status.inspect
    end
  2. And a file named "features/result.feature" with:
    features/docs/writing_support_code/after_hooks.feature:21
    Feature:
      Scenario:
        Given this step <result>
  3. When I run `cucumber -f progress`
    features/docs/writing_support_code/after_hooks.feature:27
  4. Then the output should contain "<status symbol>"
    features/docs/writing_support_code/after_hooks.feature:28

Examples

result
status symbol
passes
:passed
fails
:failed
is pending
:pending
features/docs/writing_support_code/after_hooks.feature:36

Scenario: Check the failed status of a scenario in a hook

  1. Given a file named "features/support/debug_hook.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    After do |scenario|
      if scenario.failed?
        puts "eek"
      end
    end
  2. And a file named "features/fail.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        Given this step fails
  3. When I run `cucumber -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    eek
features/docs/writing_support_code/after_hooks.feature:57

Scenario: Make a scenario fail from an After hook

  1. Given a file named "features/support/bad_hook.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    After do
      fail 'yikes'
    end
  2. And a file named "features/pass.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        Given this step passes
  3. When I run `cucumber -f pretty`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should fail with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
      Scenario:                # features/pass.feature:2
        Given this step passes # features/step_definitions/steps.rb:1
          yikes (RuntimeError)
          ./features/support/bad_hook.rb:2:in `After'
features/docs/writing_support_code/after_hooks.feature:79

Scenario: After hooks are executed in reverse order of definition

  1. Given a file named "features/support/hooks.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    After do
      puts "First"
    end
    
    After do
      puts "Second"
    end
  2. And a file named "features/pass.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        Given this step passes
  3. When I run `cucumber -f progress`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Second
    
    First
@spawn

Feature: Around hooks


In order to support transactional scenarios for database libraries
that provide only a block syntax for transactions, Cucumber should
permit definition of Around hooks.

features/docs/writing_support_code/around_hooks.feature:8

Scenario: A single Around hook

  1. Given a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Then /^the hook is called$/ do
      expect($hook_called).to be true
    end
  2. And a file named "features/support/hooks.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Around do |scenario, block|
      $hook_called = true
      block.call
    end
  3. And a file named "features/f.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Around hooks
      Scenario: using hook
        Then the hook is called
  4. When I run `cucumber features/f.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Around hooks
    
      Scenario: using hook      # features/f.feature:2
        Then the hook is called # features/step_definitions/steps.rb:1
    
    1 scenario (1 passed)
    1 step (1 passed)
    
features/docs/writing_support_code/around_hooks.feature:41

Scenario: Multiple Around hooks

  1. Given a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Then /^the hooks are called in the correct order$/ do
      expect($hooks_called).to eq ['A', 'B', 'C']
    end
  2. And a file named "features/support/hooks.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Around do |scenario, block|
      $hooks_called ||= []
      $hooks_called << 'A'
      block.call
    end
    
    Around do |scenario, block|
      $hooks_called ||= []
      $hooks_called << 'B'
      block.call
    end
    
    Around do |scenario, block|
      $hooks_called ||= []
      $hooks_called << 'C'
      block.call
    end
  3. And a file named "features/f.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Around hooks
      Scenario: using multiple hooks
        Then the hooks are called in the correct order
  4. When I run `cucumber features/f.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Around hooks
    
      Scenario: using multiple hooks                   # features/f.feature:2
        Then the hooks are called in the correct order # features/step_definitions/steps.rb:1
    
    1 scenario (1 passed)
    1 step (1 passed)
    
features/docs/writing_support_code/around_hooks.feature:87

Scenario: Mixing Around, Before, and After hooks

  1. Given a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Then /^the Around hook is called around Before and After hooks$/ do
      expect($hooks_called).to eq ['Around', 'Before']
    end
  2. And a file named "features/support/hooks.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Around do |scenario, block|
      $hooks_called ||= []
      $hooks_called << 'Around'
      block.call
      $hooks_called << 'Around'
      $hooks_called.should == ['Around', 'Before', 'After', 'Around'] #TODO: Find out why this fails using the new rspec expect syntax.
    end
    
    Before do |scenario|
      $hooks_called ||= []
      $hooks_called << 'Before'
    end
    
    After do |scenario|
      $hooks_called ||= []
      $hooks_called << 'After'
      expect($hooks_called).to eq ['Around', 'Before', 'After']
    end
  3. And a file named "features/f.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Around hooks
      Scenario: Mixing Around, Before, and After hooks
        Then the Around hook is called around Before and After hooks
  4. When I run `cucumber features/f.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Around hooks
    
      Scenario: Mixing Around, Before, and After hooks               # features/f.feature:2
        Then the Around hook is called around Before and After hooks # features/step_definitions/steps.rb:1
    
    1 scenario (1 passed)
    1 step (1 passed)
    
features/docs/writing_support_code/around_hooks.feature:134

Scenario: Around hooks with tags

  1. Given a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Then /^the Around hooks with matching tags are called$/ do
      expect($hooks_called).to eq ['one', 'one or two']
    end
  2. And a file named "features/support/hooks.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Around('@one') do |scenario, block|
      $hooks_called ||= []
      $hooks_called << 'one'
      block.call
    end
    
    Around('@one,@two') do |scenario, block|
      $hooks_called ||= []
      $hooks_called << 'one or two'
      block.call
    end
    
    Around('@one', '@two') do |scenario, block|
      $hooks_called ||= []
      $hooks_called << 'one and two'
      block.call
    end
    
    Around('@two') do |scenario, block|
      $hooks_called ||= []
      $hooks_called << 'two'
      block.call
    end
  3. And a file named "features/f.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Around hooks
      @one
      Scenario: Around hooks with tags
        Then the Around hooks with matching tags are called
  4. When I run `cucumber -q -t @one features/f.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Around hooks
    
      @one
      Scenario: Around hooks with tags
        Then the Around hooks with matching tags are called
    
    1 scenario (1 passed)
    1 step (1 passed)
    
features/docs/writing_support_code/around_hooks.feature:188

Scenario: Around hooks with scenario outlines

  1. Given a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Then /^the hook is called$/ do
      expect($hook_called).to be true
    end
  2. And a file named "features/support/hooks.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Around do |scenario, block|
      $hook_called = true
      block.call
    end
  3. And a file named "features/f.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Around hooks with scenario outlines
      Scenario Outline: using hook
        Then the hook is called
    
        Examples:
          | Number |
          | one    |
          | two    |
  4. When I run `cucumber features/f.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then it should pass with:
    aruba-0.6.2/lib/aruba/cucumber.rb:205
    Feature: Around hooks with scenario outlines
    
      Scenario Outline: using hook # features/f.feature:2
        Then the hook is called    # features/f.feature:3
    
        Examples: 
          | Number |
          | one    |
          | two    |
    
    2 scenarios (2 passed)
    2 steps (2 passed)
    
features/docs/writing_support_code/around_hooks.feature:231

Scenario: Around Hooks and the Custom World

  1. Given a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Then /^the world should be available in the hook$/ do
      $previous_world = self
      expect($hook_world).to eq(self)
    end
    
    Then /^what$/ do
      expect($hook_world).not_to eq($previous_world)
    end
  2. And a file named "features/support/hooks.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Around do |scenario, block|
      $hook_world = self
      block.call
    end
  3. And a file named "features/f.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Around hooks
      Scenario: using hook
        Then the world should be available in the hook
    
      Scenario: using the same hook
        Then what
  4. When I run `cucumber features/f.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  5. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7

Feature: Before Hook

features/docs/writing_support_code/before_hook.feature:3

Scenario: Examine names of scenario and feature

  1. Given a file named "features/foo.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Feature name
    
      Scenario: Scenario name
        Given a step
  2. And a file named "features/support/hook.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    names = []
    Before do |scenario|
      expect(scenario).to_not respond_to(:scenario_outline)
      names << scenario.feature.name.split("\n").first
      names << scenario.name.split("\n").first
      if(names.size == 2)
        raise "NAMES:\n" + names.join("\n") + "\n"
      end
    end
  3. When I run `cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
      NAMES:
      Feature name
      Scenario name
    
features/docs/writing_support_code/before_hook.feature:32

Scenario: Examine names of scenario outline and feature

  1. Given a file named "features/foo.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: Feature name
    
      Scenario Outline: Scenario Outline name
        Given a <placeholder>
    
        Examples: Examples Table name
          | <placeholder> |
          | step          |
  2. And a file named "features/support/hook.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    names = []
    Before do |scenario|
      names << scenario.scenario_outline.feature.name.split("\n").first
      names << scenario.scenario_outline.name.split("\n").first
      names << scenario.name.split("\n").first
      if(names.size == 3)
        raise "NAMES:\n" + names.join("\n") + "\n"
      end
    end
  3. When I run `cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
          NAMES:
          Feature name
          Scenario Outline name, Examples Table name (#1)
          Scenario Outline name, Examples Table name (#1)
    
@spawn

Feature: Hooks execute in defined order

Background

  1. Given a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given /^background step$/ do; $EventOrder.push(:background_step) end
    Given /^scenario step$/ do; $EventOrder.push(:scenario_step) end
  2. And a file named "features/support/hooks.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    $EventOrder = []
    Around('@around') do |scenario,block|
      $EventOrder.push :around_begin
      block.call
      $EventOrder.push :around_end
    end
    Before('@before') do
      $EventOrder.push :before
    end
    After('@after') do |scenario|
      $EventOrder.push :after
    end
    at_exit {
      puts "Event order: #{$EventOrder.join(' ')}"
    }
  3. And a file named "features/around_hook_covers_background.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    @around
    Feature: Around hooks cover background steps
      Background:
        Given background step
      Scenario:
        Given scenario step
  4. And a file named "features/all_hook_order.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    @around
    @before
    @after
    Feature: All hooks execute in expected order
      Background:
        Given background step
      Scenario:
        Given scenario step
features/docs/writing_support_code/hook_order.feature:49

Scenario: Around hooks cover background steps

  1. When I run `cucumber -o /dev/null features/around_hook_covers_background.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Event order: around_begin background_step scenario_step around_end
features/docs/writing_support_code/hook_order.feature:56

Scenario: All hooks execute in expected order

  1. When I run `cucumber -o /dev/null features/all_hook_order.feature`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then the output should contain:
    aruba-0.6.2/lib/aruba/cucumber.rb:156
    Event order: around_begin before background_step scenario_step after around_end

Feature: Set up a default load path


When you're developing a gem, it's convenient if your project's `lib` directory
is already in the load path. Cucumber does this for you.

features/docs/writing_support_code/load_path.feature:6

Scenario: ./lib is included in the $LOAD_PATH

  1. Given a file named "features/support/env.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    require 'something'
  2. And a file named "lib/something.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    class Something
    end
  3. When I run `cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7

Feature: State


You can pass state between step by setting instance variables,
but those instance variables will be gone when the next scenario runs.

features/docs/writing_support_code/state.feature:6

Scenario: Set an ivar in one scenario, use it in the next step

  1. Given a file named "features/test.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature:
      Scenario:
        Given I have set @flag = true
        Then @flag should be true
    
      Scenario:
        Then @flag should be nil
  2. And a file named "features/step_definitions/steps.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Given /set @flag/ do
      @flag = true
    end
    Then /flag should be true/ do
      expect(@flag).to be_truthy
    end
    Then /flag should be nil/ do
      expect(@flag).to be_nil
    end
  3. When I run `cucumber`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  4. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7

Feature: Tagged hooks

Background

  1. Given the standard step definitions
    features/lib/step_definitions/cucumber_steps.rb:19
  2. And a file named "features/support/hooks.rb" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Before('~@no-boom') do 
      raise 'boom'
    end
  3. And a file named "features/f.feature" with:
    aruba-0.6.2/lib/aruba/cucumber.rb:29
    Feature: With and without hooks
      Scenario: using hook
        Given this step passes
    
      @no-boom
      Scenario: omitting hook
        Given this step passes
    
      Scenario Outline: omitting hook on specified examples
        Given this step passes
    
        Examples:
        | Value       |
        | Irrelevant  |
    
        @no-boom
        Examples:
        | Value           |
        | Also Irrelevant |
features/docs/writing_support_code/tagged_hooks.feature:34

Scenario: omit tagged hook

  1. When I run `cucumber features/f.feature:2`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: With and without hooks
    
      Scenario: using hook     # features/f.feature:2
      boom (RuntimeError)
      ./features/support/hooks.rb:2:in `Before'
        Given this step passes # features/step_definitions/steps.rb:1
    
    Failing Scenarios:
    cucumber features/f.feature:2 # Scenario: using hook
    
    1 scenario (1 failed)
    1 step (1 skipped)
    0m0.012s
    
features/docs/writing_support_code/tagged_hooks.feature:54

Scenario: omit tagged hook

  1. When I run `cucumber features/f.feature:6`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: With and without hooks
    
      @no-boom
      Scenario: omitting hook  # features/f.feature:6
        Given this step passes # features/step_definitions/steps.rb:1
    
    1 scenario (1 passed)
    1 step (1 passed)
    0m0.012s
    
features/docs/writing_support_code/tagged_hooks.feature:69

Scenario: Omit example hook

  1. When I run `cucumber features/f.feature:12`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should fail with exactly:
    aruba-0.6.2/lib/aruba/cucumber.rb:209
    Feature: With and without hooks
    
      Scenario Outline: omitting hook on specified examples # features/f.feature:9
        Given this step passes                              # features/f.feature:10
    
        Examples: 
          | Value      |
          boom (RuntimeError)
          ./features/support/hooks.rb:2:in `Before'
          | Irrelevant |
    
    Failing Scenarios:
    cucumber features/f.feature:14 # Scenario Outline: omitting hook on specified examples, Examples (#1)
    
    1 scenario (1 failed)
    1 step (1 skipped)
    0m0.012s
    
features/docs/writing_support_code/tagged_hooks.feature:92

Scenario:

  1. When I run `cucumber features/f.feature:17`
    aruba-0.6.2/lib/aruba/cucumber.rb:93
  2. Then it should pass
    features/lib/step_definitions/aruba_steps.rb:7