-
Book Overview & Buying
-
Table Of Contents
Cucumber Cookbook
By :
Feature files contain possible Scenarios for a particular functionality. This is like writing all possible requirements that a Feature should meet when it is implemented. So let's write these specifications in Cucumber in the following section.
We will create a new Feature file called home_page.feature, which will cover the functionality of the default content of https://github.com/, the Bootcamp section, and the top banner content. We will create a different Scenario for each functionality. Take a look at the following screenshot for more clarity:

Feature: Home Page
In order to test Home Page of application
As a Registered user
I want to specify the features of home page
Scenario: Home Page Default content
Given user is on Github home page
Then user gets a GitHub bootcamp section
And username is also displayed on right corner
Scenario: GitHub Bootcamp Section
Given user is on GitHub home page
When user focuses on GitHub Bootcamp Section
Then user gets an option to setup git
And user gets an option to create repository
And user gets an option to Fork Repository
And user gets an option to work together
Scenario: Top Banner content
Given user is on GitHub home page
When user focuses on Top Banner
Then user gets an option of home page
And user gets an option to search
And user gets settings options
And user gets an option to logoutA Cucumber Feature file can have any number of Scenarios as required. Some points to keep in mind are as follows:
When we have multiple Scenarios in a Feature file, we should always follow the Stateless Scenarios Guideline. Let's understand this guideline better—each Scenario must make sense and should be executed independently of any other Scenario. The result of one Scenario/Feature should not affect the other Scenario.
These are the benefits of independent Scenarios:
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Change the font size
Change margin width
Change background colour