Behavior Driven Development Framework
BDD is a software development process which is used to illustrate the behavior of the system in a simple English language. This makes it even easier for non-technical team member to understand the project.
BDD has emerged from Test Driven Development(TDD) where tests are written by focusing on user stories and system behavior. Code is written using languages like Java, Python.
Why Use BDD Framework?
The issue with TDD was that every member of the project was required to have knowledge of coding, which was simplified using BDD framework. BDD helped to overcome the gap between technical and non-technical team, because all the test cases were written in a language easily understood by everyone - English!
There are several tools used in BDD Framework, lets look into one of such tools called Cucumber.
Image: rapid7.com
What is Cucumber?
Cucumber is BDD tool which is used to write test cases, it supports test automation and documentation. In Cucumber, Features, Scenarios and Steps are written in a language called Gherkin.
Gherkin is easy to understand as its written in plain English text with a structure. It describes use cases in a way which is understood by everyone. It promotes behavior-driven development because it allows developers, managers, business analysts and other parties involved to understand the requirements of the project and the life-cycle.
Syntax of Gherkin:
Given: Available preconditions
When: Action to be performed
Then: Expected Outcome
Image: testmanagement.com
Lets write Gherkin Scripts for the features of Instagram!
Feature 1: Testing login page of Instagram
Scenario 1: To check if email field is displayed in login page.
Given you enter valid url of instagram (https://www.instagram.com/)
When you click on the email id field
Then the cursor should point in the email id field
Scenario 2: Entering valid data in email field
Given you are in instagram login page
When Email field is displayed
Then enter valid email id in the field
Scenario 3: Entering valid data in password field
Given you are in instagram login page
When password field is displayed
Then enter valid password in password field
Scenario 4: Logging into instagram account
Given you are in instagram login page
When you submit valid email id and password
Then you are logged into your account
Scenario 5: Checking for error messages in login page
Given you are in login page
When you submit invalid credentials
Then Error message is displayed
Scenario 6: Testing the forgot password link
Given you are in instagram login page
When “Forgot password” link is displayed
Then clicking on the link should direct you to “Password reset” page
Scenario 7: Testing the email field in password reset page
Given you are in password reset page
When submit valid email id
Then password reset email should be sent
Scenario 8: Going back to login page from password reset page
Given you are in password reset page
When Clicked on “Back to login” link
Then should be directed to login page
Scenario 9: Logging in with facebook
Given you are in login page of instagram
When you click on “Log in with Facebook”
Then you should be directed to Facebook login page
Scenario 10: Clicking on Sign up link in Login page
Given you are in login page of instagram
When you click on “Sign up” link
Then you should be directed to Sign up page
Feature 2 : Testing the home page
Scenario 1: Going to home page
Given you enter valid credentials in login page
When you click on login link
Then it should direct to home page
Scenario 2: Test the search field
Given you are logged in your account
When you are in home page
Then Search field should be displayed
Scenario 3: Suggestions should be displayed below search field
Given you are in home page
And Search field is displayed
When you enter valid name in the search field
Then suggestions should be displayed
Scenario 4: Instagram logo should take you to the top of the home page
Given you have scrolled down in the home page
When you click on instagram icon
Then you should be scrolled to the top most feed in home page
Scenario 5: Clicking on “Clear All” link should delete all the recently searched terms
Given you are in home page
When you click on “Clear all” link below search field
Then it should delete all the recently searched terms
Scenario 6: Home icon should be in black color
Given you are logged into your account
When you are in home page
Then the home icon should be in black color
Scenario 7: Home icon should be in white color
Given you are logged into your account
When you are not in home page
Then the home icon should be in white color
Scenario 8: Clicking on message icon should take us to inbox
Given you are in home page
When you click on message icon
Then it should take us to inbox page
Scenario 9: Clicking on one of the messages should take us to respective message
Given you are in inbox page
When you click on one of the message
Then the respective message is opened
Scenario 10: Clicking on new message icon should pop up list of friends name
Given you are in inbox page
When you click on new message icon
Then it should pop up list of friends name
Feature 3: Signup page
Scenario 1: Clicking on signup link in login page should take us to signup page
Given you are in login page
When you click on “Sign up” link
Then It should take us to Sign up page
Scenario 2 : “Log in with Facebook” button is displayed in signup page
Given you have opened the instagram page
When you click on sign up page
Then “Log in with Facebook” button should be displayed
Scenario 3 : Signing up with new account details
Given you are in signup page
When you enter valid details in all the fields
And Click on signup button
Then you should be successfully signed up
Scenario 4: Signing up with invalid data should throw an error
Given you are in signup page
When you enter invalid details in any of the fields in signup page
Then Error message should be displayed
Scenario 5: “Log in” link should be displayed in signup page
Given you are in instagram web page
When you click on signup page
Then “Log in” link should be displayed in bottom of the page
Scenario 6: Clicking on “Login” link in signup page should take us to login page
Given you are in sign up page
When you click on login link
Then login page should be opened
Scenario 7: “Terms” , “Data Policy” and “Cookies Policy” links should be displayed in Signup page
Given you have opened instagram website
When you click on sign up link
Then in “Signup” page “Terms” , “Data Policy” and “Cookies Policy” links should be displayed.
Feature 4 : Profile page
Scenario 1: Profile icon should be displayed in home page
Given you are logged into your account
When you click on profile photo
Then it should display “Profile”, “Saved”, “Settings”, “Switch Accounts” and “Log out” links should be displayed
Scenario 2: Clicking on profile link should take us to profile page
Given you are logged into your account
And Click on the photo icon
When you click on “profile” link
Then it should take us to profile page
Scenario 3: Edit profile link should be displayed in profile page
Given you are logged into your account
When you are in your profile page
Then “Edit profile” link should be displayed
Scenario 4: “Edit Profile” link should take us to accounts edit page
Given you are in your profile page
When you click on edit profile link
Then It should take us to accounts edit page
Scenario 5: Submit button should be displayed in accounts edit page
Given you are logged into your account
When you go to accounts edit page
Then submit button should be disabled
Scenario 6: Clicking on “Change password” link should take us to password change page
Given you are logged into your account
And you are in “Edit profile” page
When you click on “Change Password” link
Then it should take us to Password change page
Scenario 7: Going to manage access page
Given you are logged into your account
And you are in edit profile page
When you click on “Apps and Websites” link
Then you should be directed to manage access page
Scenario 8: Going to email settings page from edit profile page
Given you are logged into your account
And you are in edit profile page
When you click on “Email and SMS” link
Then it should direct to email settings page
Scenario 9: Checkboxes in email settings page
Given you are logged into your account
And you are in edit profile page
When you navigate to email settings page
Then user should be able to check/uncheck the boxes
Scenarios 10: Push notifications in web settings page
Given you are logged into your account
And you are in edit profile page
When you click on “Push notifications” link
Then user should be able to turn on/off the radio buttons.
Scenarios 11: “Switch to professional account” link in edit profile page
Given you are logged into your account
And you are in edit profile page
When you click on “Switch to professional account”
Then you should be directed to convert to professional account page.
Scenario 12 : Login out of your account
Given you are logged into your account
When you hover on your profile photo
And click on “Logout”
Then you should be successfully logged out of your account