Note
The feature stanza is never executed, but it is parsed. The “Feature:” label MUST be present at the top of each feature file.
Given: Defines the initial state of the system for the scenario
Given I am on the homepage
When: Describes the action performed on the system
When I press "Log in"
Then: Describes the system state after the action has been performed
Then I should see "Username field is required"
And, But: Can be added to any of the above
And I should see "Password field is required"
features/login.feature
Feature: Maintain content
In order to maintain site content
As an editor
I need to log in
Scenario: Enter valid username and password // Happy path
Given I am on the homepage
When I fill in "admin" for "Username"
And I fill in "admin" for "Password"
And I press "Log in"
Then I should see "Add content"
Scenario: Fail to enter username or password // Less happy path
Given I am on the homepage
When I press "Log in"
Then I should see "Username field is required"
And I should see "Password field is required"
Once a step definition is written in PHP, the step can be re-used:
Scenario: Access free content
Given I am on "/series/learning-sass-and-compass"
When I follow "What is a CSS Preprocessor?"
Then I should see "What is a CSS Preprocessor?"
And I should see "Interactive Transcripts"