| 1 |
Feature: Core: Scenarios, Steps, Mappings |
| 2 |
|
| 3 |
Cucumber is a tool for executing business-readable specifications |
| 4 |
written in Gherkin. The basic unit of both specification and |
| 5 |
execution is the Scenario. A Scenario is a list of steps, each of |
| 6 |
which representing an action performed by a user (or user agent) |
| 7 |
on the software product under development. When a Scenario is |
| 8 |
executed, its steps are applied to the software system in the order |
| 9 |
they are contained in the Scenario. |
| 10 |
|
| 11 |
Gherkin is not a programming language, so in order to execute steps |
| 12 |
written in it, Cucumber must first look up a mapping from the text of |
| 13 |
each step to a function. If such a mapping exists, the function is |
| 14 |
executed, and the result is communicated to the user. |
| 15 |
|
| 16 |
Scenario: All steps passing means the scenario passes |
| 17 |
Given a scenario with: |
| 18 |
""" |
| 19 |
When I add 4 and 5 |
| 20 |
Then the result is 9 |
| 21 |
""" |
| 22 |
And the step "I add 4 and 5" has a passing mapping |
| 23 |
And the step "the result is 9" has a passing mapping |
| 24 |
When Cucumber executes the scenario |
| 25 |
Then the scenario passes |
| 26 |
|
| 27 |
Scenario: Failing step means the scenario fails |
| 28 |
Given a scenario with: |
| 29 |
""" |
| 30 |
When I add 4 and 5 |
| 31 |
Then the result is 9 |
| 32 |
""" |
| 33 |
And the step "I add 4 and 5" has a failing mapping |
| 34 |
And the step "the result is 9" has a passing mapping |
| 35 |
When Cucumber executes the scenario |
| 36 |
Then the scenario fails |
| 37 |
And the step "the result is 9" is skipped |
| 38 |
|
| 39 |
Scenario: Pending step means the scenario is pending |
| 40 |
Given a scenario with: |
| 41 |
""" |
| 42 |
When I add 4 and 5 |
| 43 |
Then the result is 9 |
| 44 |
""" |
| 45 |
And the step "I add 4 and 5" has a pending mapping |
| 46 |
And the step "the result is 9" has a passing mapping |
| 47 |
When Cucumber executes the scenario |
| 48 |
Then the scenario is pending |
| 49 |
And the step "the result is 9" is skipped |
| 50 |
|
| 51 |
Scenario: Missing step mapping means the scenario is undefined |
| 52 |
Given a scenario with: |
| 53 |
""" |
| 54 |
When I add 4 and 5 |
| 55 |
Then the result is 9 |
| 56 |
""" |
| 57 |
And the step "the result is 9" has a passing mapping |
| 58 |
When Cucumber executes the scenario |
| 59 |
Then the scenario is undefined |
| 60 |
And the step "the result is 9" is skipped |
| 61 |
|
| 62 |
Scenario: Feature headers |
| 63 |
Given the following feature: |
| 64 |
""" |
| 65 |
Feature: a feature |
| 66 |
In order to get results |
| 67 |
As a user |
| 68 |
I want to do something |
| 69 |
""" |
| 70 |
When Cucumber runs the feature |
| 71 |
Then the feature passes |
| 72 |
|
| 73 |
Scenario: Simple flat steps |
| 74 |
Given a scenario with: |
| 75 |
""" |
| 76 |
Given a calculator |
| 77 |
When the calculator computes PI |
| 78 |
Then the calculator returns PI |
| 79 |
""" |
| 80 |
When Cucumber runs the scenario with steps for a calculator |
| 81 |
Then the scenario passes |
| 82 |
|
| 83 |
Scenario: Given, When, Then, And and But steps |
| 84 |
Given a scenario with: |
| 85 |
""" |
| 86 |
Given a calculator |
| 87 |
When the calculator adds up 1 and 2 |
| 88 |
And the calculator adds up 3 and 0.14159265 |
| 89 |
Then the calculator returns PI |
| 90 |
But the calculator does not return 3 |
| 91 |
""" |
| 92 |
When Cucumber runs the scenario with steps for a calculator |
| 93 |
Then the scenario passes |
| 94 |
|
| 95 |
Scenario: Failing steps |
| 96 |
Given a scenario with: |
| 97 |
""" |
| 98 |
Given a calculator |
| 99 |
When the calculator adds up 3 and 0.14 |
| 100 |
Then the calculator returns PI |
| 101 |
""" |
| 102 |
When Cucumber runs the scenario with steps for a calculator |
| 103 |
Then the scenario fails |
| 104 |
|
| 105 |
Scenario: Single-parameter step |
| 106 |
Given a scenario with: |
| 107 |
""" |
| 108 |
Given a calculator |
| 109 |
When the calculator computes PI |
| 110 |
Then the calculator returns "3.14159265" |
| 111 |
""" |
| 112 |
When Cucumber runs the scenario with steps for a calculator |
| 113 |
Then the scenario passes |
| 114 |
|
| 115 |
Scenario: Two-parameter step |
| 116 |
Given a scenario with: |
| 117 |
""" |
| 118 |
Given a calculator |
| 119 |
When the calculator adds up "12" and "51" |
| 120 |
Then the calculator returns "63" |
| 121 |
""" |
| 122 |
When Cucumber runs the scenario with steps for a calculator |
| 123 |
Then the scenario passes |
| 124 |
|
| 125 |
Scenario: Two-parameter step failing |
| 126 |
Given a scenario with: |
| 127 |
""" |
| 128 |
Given a calculator |
| 129 |
When the calculator adds up "12" and "51" |
| 130 |
Then the calculator returns "65" |
| 131 |
""" |
| 132 |
When Cucumber runs the scenario with steps for a calculator |
| 133 |
Then the scenario fails |
| 134 |
|
| 135 |
Scenario: Three-parameter step |
| 136 |
Given a scenario with: |
| 137 |
""" |
| 138 |
Given a calculator |
| 139 |
When the calculator adds up "3", "4" and "5" |
| 140 |
Then the calculator returns "12" |
| 141 |
""" |
| 142 |
When Cucumber runs the scenario with steps for a calculator |
| 143 |
Then the scenario passes |