• swatiiashok

BEHAVIOR DRIVEN DEVELOPMENT WITH GHERKIN

Updated: 6 days ago

Behavior Driven Development(BDD) is a software development approach that has emerged from Test Driven Development. Both approaches create tests before the coding begins.


Test Driven Development(TDD), focuses more on implementation of the feature, which follows a simple five step process.


  1. Write a test

  2. Run the test and show its fails (red)

  3. Write the code that meets the need of test

  4. Run the test till it passes(green)

  5. Refactor



TDD Cycle



Whereas Behavior Driven Test(BDD),focuses more on systems behavior through examples in simple domain specific language. It is more of an agile ‘as a user’ approach. It improves the communication between tech, non-tech and stakeholders as it uses plain text language called Gherkin.



BDD-Gherkin


Gherkin is a domain specific language which helps to describe business behavior without going into implementation details. Gherkin is designed in such a way even a non programmer can follow.


Gherkin Keywords:


Features: describes the feature

Scenarios: describes the behavior of the system

Steps : Given -> sets up initial state

When -> performs an action

Then -> verify outcomes

You can add And,But to any type of steps as needed.


Here goes some examples using Gherkin,


Feature: Shopping in Amazon


Scenario: login Amazon with valid credentials

Given the user is on amazon login page

When the user entered valid email address and password

And press enter

Then it shows “Hello, Your name” in the top of the home page.


Scenario: invalid username

Given the user wants to sign in to amazon

When the user enter invalid email address and press enter

Then it should pop up “There was a problem We cannot find an account with that email address”


Scenario: invalid password

Given the user wants to sign in to amazon

When the user enter valid email address and invalid password and press enter

Then it should pop up “There was a problem Your password is incorrect ”


Scenario: forgot password

Given the user wants to sign in to amazon

When the user enter valid email address and press enter

And clicks the “forgot your password”

Then it should pop up “Password assistance” window

And ask the user to enter email id or phone number and press continue


Scenario: change the user name before entering the password

Given the user wants to sign in to amazon

And the user entered valid email address and press enter

When the user wants to sign in using different email id

Then the user should click on “change” near the given email id


Scenario: Search for an item

Given the user in amazon website

When the user enter the item, you want to search in the search bar and press enter

Then the user should see products related to the search made.


Scenario: add product to the cart

Given the user is in the product page that he want to buy

When the user click "add to cart"

Then the item should be added to the cart


Scenario: not logged in and trying to place an order

Given the user have added items without logging in

When the user click “Proceed to checkout”

Then it should redirect to login page


Scenario: get a free shipping without prime membership

Given the user logged in and added items to the cart

When the user’s cart subtotal is more than $25

And the items are shipped and sold by amazon

Then the user is qualified for free shipping


Scenario: looking for products which are only prime

Given the user has a prime membership

When the user search for a particular product

And the user selected the prime checkbox

Then users search results should only show prime products


Scenario: deleting items from the cart

Given the user have added some items in the cart

When the user click delete the item in the shopping cart

Then the item is deleted and not showing in the cart again


Scenario: increasing the quantity in the shopping cart

Given user have added some items in the cart

When the user increase the quantity of the item in the shopping cart

Then it should show the selected quantity in the field

And the price should change accordingly


Scenario: to see prime videos in your prime account

Given the user have prime account and logged in

When the user click on “Prime Video” tab on the home page

Then the user should redirect to Prime Video page


Scenario: to do shopping in Whole Foods from amazon home page

Given the user is logged in as amazon prime customer

When the user click Whole Foods tab

Then it should redirect to whole foods page


Scenario: to check items added by Alexa to my shopping list

Given the user have asked Alexa to add some items in the shopping list

When the user click the “Alexa lists” in the home page

Then it should show the items user have asked to add


Scenario: to check the user orders

Given the user placed some orders in amazon

When the user click “Returns and Orders” tab

Then it should redirect to “Returns and Orders” page where it shows all your past orders


Scenario: to track users orders

Given the user placed some orders

When the user click “Track Package” under “Orders”

Then it should redirect to “Track Package” page where it shows the status of the order


Scenario: cancel the order

Given the user have placed an order in amazon

And the user want cancel the order

When the user go to “Your Orders”

And select the item to be canceled

And click "cancel the order"

Then the users order will be canceled


Scenario: setting “Your Amazon day”

Given the user is an amazon customer

And placed orders where it arrives in different days

And the user wants all the package to arrive in the same day

When the user set preference under “Amazon Day Delivery” to a particular

Then it should show the users Amazon day to that particular day.


Scenario: to change the delivery address

Given the user have an amazon account

When the user want to place an order to a different address

Then in checkout page, add the new address the user want to deliver or change the address under Shipping address


Scenario: apply promotion code

Given: you have added items in the cart

And: clicked to checkout page

When: you enter promotion code inside “enter code”

And: click apply

Then: if it’s a valid code it should change the price accordingly


Scenario: to change the payment method

Given the user have added the items in the cart

And proceeded to check out page

When the user want to change the payment method

Then click "change payment method"

And choose or add the card as user wants


Scenario: to go to amazon home page

Given the user is shopping inside amazon site

When the user currently in checkout page or under some product page

And want to redirect to home page

Then click on “Amazon” icon on the top left to go to home page


Scenario: see the ratings for the product

Given the user searched for a product

When the user click the ratings link under the product description

Then it shows customer reviews and stars for that particular product


Scenario: signing out from user’s account

Given the user signed into amazon

And the user wants to sign out from amazon

When the user clicked sign out under "your account"

Then the user come back to amazon homepage where it shows sign in on top of the page
















7 views0 comments

Recent Posts

See All

BDD - GHERKIN FOR OCTOPARSE APPLICATION

Octoparse is a web scrapping tool used to extract web data without coding.You can use the free version where you can work up to ten task or paid subscription with more service included. Let's see some

 

© Numpy Ninja.