Skip to content
This repository
branch: master
Julien Biezemans October 28, 2011
file 144 lines (129 sloc) 4.522 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
Feature: Core: Scenarios, Steps, Mappings

Cucumber is a tool for executing business-readable specifications
written in Gherkin. The basic unit of both specification and
execution is the Scenario. A Scenario is a list of steps, each of
which representing an action performed by a user (or user agent)
on the software product under development. When a Scenario is
executed, its steps are applied to the software system in the order
they are contained in the Scenario.

Gherkin is not a programming language, so in order to execute steps
written in it, Cucumber must first look up a mapping from the text of
each step to a function. If such a mapping exists, the function is
executed, and the result is communicated to the user.

Scenario: All steps passing means the scenario passes
Given a scenario with:
"""
When I add 4 and 5
Then the result is 9
"""
And the step "I add 4 and 5" has a passing mapping
And the step "the result is 9" has a passing mapping
When Cucumber executes the scenario
Then the scenario passes

Scenario: Failing step means the scenario fails
Given a scenario with:
"""
When I add 4 and 5
Then the result is 9
"""
And the step "I add 4 and 5" has a failing mapping
And the step "the result is 9" has a passing mapping
When Cucumber executes the scenario
Then the scenario fails
And the step "the result is 9" is skipped

Scenario: Pending step means the scenario is pending
Given a scenario with:
"""
When I add 4 and 5
Then the result is 9
"""
And the step "I add 4 and 5" has a pending mapping
And the step "the result is 9" has a passing mapping
When Cucumber executes the scenario
Then the scenario is pending
And the step "the result is 9" is skipped

Scenario: Missing step mapping means the scenario is undefined
Given a scenario with:
"""
When I add 4 and 5
Then the result is 9
"""
And the step "the result is 9" has a passing mapping
When Cucumber executes the scenario
Then the scenario is undefined
And the step "the result is 9" is skipped

Scenario: Feature headers
Given the following feature:
"""
Feature: a feature
In order to get results
As a user
I want to do something
"""
When Cucumber runs the feature
Then the feature passes

Scenario: Simple flat steps
Given a scenario with:
"""
Given a calculator
When the calculator computes PI
Then the calculator returns PI
"""
When Cucumber runs the scenario with steps for a calculator
Then the scenario passes

Scenario: Given, When, Then, And and But steps
Given a scenario with:
"""
Given a calculator
When the calculator adds up 1 and 2
And the calculator adds up 3 and 0.14159265
Then the calculator returns PI
But the calculator does not return 3
"""
When Cucumber runs the scenario with steps for a calculator
Then the scenario passes

Scenario: Failing steps
Given a scenario with:
"""
Given a calculator
When the calculator adds up 3 and 0.14
Then the calculator returns PI
"""
When Cucumber runs the scenario with steps for a calculator
Then the scenario fails

Scenario: Single-parameter step
Given a scenario with:
"""
Given a calculator
When the calculator computes PI
Then the calculator returns "3.14159265"
"""
When Cucumber runs the scenario with steps for a calculator
Then the scenario passes

Scenario: Two-parameter step
Given a scenario with:
"""
Given a calculator
When the calculator adds up "12" and "51"
Then the calculator returns "63"
"""
When Cucumber runs the scenario with steps for a calculator
Then the scenario passes

Scenario: Two-parameter step failing
Given a scenario with:
"""
Given a calculator
When the calculator adds up "12" and "51"
Then the calculator returns "65"
"""
When Cucumber runs the scenario with steps for a calculator
Then the scenario fails

Scenario: Three-parameter step
Given a scenario with:
"""
Given a calculator
When the calculator adds up "3", "4" and "5"
Then the calculator returns "12"
"""
When Cucumber runs the scenario with steps for a calculator
Then the scenario passes
Something went wrong with that request. Please try again.