A money-transfer scenario is easier to discuss when it separates the starting balances, the transfer, and the resulting balances. Each of those statements is a step: one part of a Gherkin scenario that business stakeholders and developers can read together and potentially automate. section 2.3.5
Feature: Transferring money between accounts
In order to manage my money more efficiently
As a bank client
I want to transfer funds between my accounts whenever I need to
Scenario: Transferring money to a savings account
Given Tess has a current account with $1000
And a savings account with $2000.00
When she transfers $500 from current to savings
Then she should have $500 in her current account
And she should have $2500 in her savings account
Scenario: Transferring with insufficient funds
Given Tess has a current account with $1000
And a savings account with $2000.00
When she transfers $1500 from current to savings
Then she should receive an 'insufficient funds' error
Then she should have $1000 in her current account
And she should have $2000 in her Savings account
The transfer scenarios show Given steps establishing balances, a When step making the transfer, and Then steps checking the outcome. section 2.3.5
Use the keyword to show what a step contributes:
- Given establishes a precondition and prepares the test environment. section 2.3.5
- When states the action under test. section 2.3.5
- Then states an expected outcome. section 2.3.5
- And or But continues the preceding kind of step while making the scenario easier to read. section 7.2.4
Keep each step focused on one relevant condition or result. Splitting a combined assertion can make changes and failures easier to locate and steps easier to reuse. But more detail is not always better: hide routine setup and navigation when they distract from the business behavior being discussed. section 7.2.4 section 7.6.6
Scenario: Search for available hotels by distance
Given Bindi needs to make a business trip to Paris
And the following hotels have available rooms:
| Hotel Name | Location | Distance from center |
| Ritz | Paris | 3.2 |
| Savoy | Paris | 6.9 |
| Hilton | Paris | 12.5 |
When Bindi searches for a hotel within 10 km of Paris
Then she should be presented with the following hotels:
| Hotel Name | Location | Distance from center |
| Ritz | Paris | 3.2 |
| Savoy | Paris | 6.9 |
The hotel-search scenario keeps the available hotels as relevant setup and checks only the hotels within the requested distance, rather than spelling out login and page navigation. section 7.6.6
Steps can contain tables when test data or expected results are clearer in rows. A scenario outline can instead repeat the same steps with values supplied by an Examples table. Choose the form that makes the requirement clear at a glance. section 2.3.5
