This section teaches the basics of Behavior Driven Development and is written in the context of writing automated tests in Magellan. It should act as a "getting started" guide for BDD beginners and should explain the different keywords used as a test is written.
What is a Behavior?
A behavior is how a feature operates. It can be defined as a scenario of inputs, actions, and outcomes. Identifying behaviors individually brings clarity and simplicity and also explains how behaviors are related. Below are examples of behaviors:
- Logging in
- Clicking links in the menu
- Submitting forms
Gherkin is one of the most popular languages for writing behavior specifications as it captures behaviors as "Given-When-Then" scenarios. The expectation is that anyone from a customer to a product owner to a configurator or tester can write BDD scenarios as they are just English phrases.
Feature File
The first primary keyword in a Gherkin document must always be Feature followed by a : and a short text that describes the feature. When a test file is created in Magellan it automatically adds the Feature keyword with the relative path of the file (minus the .feature extension)

Scenario
The keyword "Scenario" is a synonym of the keyword "Example". A feature file can contain multiple scenarios. Typically a scenario is written as per the format below
- Given [initial context]
- When [event occurs]
- Then [ensure outcome]
- And/But [more outcomes if applicable]
Steps
Each step starts with Given, When, Then , But or And. Each step in a scenario is executed one at a time, in the sequence they have been written them in. From a test execution perspective the keywords Given, When, Then, But of And are ignored and it is more from a readability standpoint only.
The following steps will be considered duplicates
- Given I click menu Users and Permissions
- Then I click menu Users and Permissions
Background
Occasionally we might find ourselves repeating the same initial context in all of the scenarios in the feature file. We can literally move those steps related to the initial context by grouping them under the Background section.
Scenario Outline
Scenario Outline keyword allows us to run the same scenario multiple times with different combinations of values. Scenario outlines allow us to more concisely express these scenarios through the use of a template with < > -delimited parameters:
Scenario Outline: Enter Physical Address
Given I set application to master
When I logon as externalUser with password externalUser
Then I select And I select option <Country> from dropdown Country
And I set text <Line1> in Number and street
And I set text <Suburb> in Suburb
And I set text <Postcode> in Postcode
Examples:
| Country | Line1 | Suburb | Postcode |
| NZ | NZ Address line 1 | Auckland | 2113 |
| Australia | Australia Address line 1 | Melbourne | 1000 |
More info located at https://cucumber.io/docs/gherkin/reference/

