Behaviour Driven Development(BDD) with Example


Behaviour Driven Development is an evolution of TDD. Behaviour Driven Development(BDD) is an software development methodology where real time application behaviour are written by product owner and user followed by development and testing is known as feature file.


In BDD, Gherkin is a natural language which used to narrate scenarios as a feature file using below keywords:

Given - Context / Staring state

When - event / what user does

Then- outcome / expected result





Below Example Feature File with 50 Scenarios



Feature: Transactions @ checkout counter Scenario 1: Using Master Credit card chip Given: You are asked to Pay for billing at checkout When: Insert your Master chip card into the chip enabled reader on the terminal Then: Remove the card once terminal indicates that the transaction is complete. Scenario 2: Using Master Credit card swipe function Given: You are asked to Pay for billing at checkout When: Swipe your master credit card magnetic stripe on the swiping terminal Then: Terminal indicates that the transaction is approved. Scenario 3: Using Master Credit card tap function Given: You are asked to Pay for billing at checkout When: Tap your Master card look for the contactless symbol (four curved lines )should appear on the terminal Then: Purchase is approved, you’ll receive confirmation typically a beep, green light or check mark. Scenario 4: Using Visa Credit card chip Given: You are asked to Pay for billing at checkout When: Insert your Visa chip card into the chip enabled reader on the terminal Then: Remove the card once terminal indicates that the transaction is complete. Scenario 5: Using Visa Credit card swipe function Given: You are asked to Pay for billing at checkout When: Swipe your Visa credit card magnetic stripe on the swiping terminal Then: Terminal indicates that the transaction is approved. Scenario 6: Using Visa Credit card tap function Given: You are asked to Pay for billing at checkout When: Tap your Visa card look for the contactless symbol (four curved lines) should appear on the terminal Then: Purchase is approved, you’ll receive confirmation typically a beep, green light or check mark. Scenario 7: Using Amex Credit card chip Given: You are asked to Pay for billing at checkout When: Insert your Amex chip card into the chip enabled reader on the terminal Then: Remove the card once terminal indicates that the transaction is complete Scenario 8: Using Amex Credit card swipe function Given: You are asked to Pay for billing at checkout When: Swipe your Amex credit card magnetic stripe on the swiping terminal Then: Terminal indicates that the transaction is approved. Scenario 9: Using Amex Credit card tap function Given: You are asked to Pay for billing at checkout When: Tap your Amex card look for the contactless symbol (four curved lines) should appear on the terminal Then: Purchase is approved, you’ll receive confirmation as a beep or green light or check mark. Scenario 10: Credit card Limit Exceed Given: You are asked to Pay for billing at checkout When: Used your credit card at the terminal got message Credit Limit Exceed Then: Transaction not approved Scenario 11: Using Debit card chip Given: You are asked to Pay for billing at checkout When: Insert your Debit chip card into the chip enabled reader on the terminal, Enter the Debit Pin Then: Remove the card once terminal indicates that the transaction is complete Scenario 12: Using Debit card swipe function Given: You are asked to Pay for billing at checkout When: Swipe your Debit credit card magnetic stripe on the swiping terminal, Enter the Debit Pin Then: Transaction is approved Scenario 13: Using Debit card tap function Given: You are asked to Pay for billing at checkout When: Tap your debit card look for the contactless symbol (four curved lines )should appear on the terminal Then: Purchase is approved, you’ll receive confirmation as a beep or green light or check mark. Scenario 14: Debit with insufficient funds Given: You are asked to Pay for billing at checkout When: You attempted a transaction that failed with the error "Insufficient funds" Then: Transaction is approved Scenario 15: Debit with invalid pin Given: You are asked to Pay for billing at checkout When: Used your Debit card with Incorrect Pin at the terminal got message “Debit card Declined” Then: Transaction not Approved Scenario 16 : Google pay with credit card or debit card Given: You are asked to Pay for billing at checkout When: Store payment terminal accepts GPay , unlock and get your phone close to the payment terminal Then: Purchase is approved, you’ll receive confirmation as a beep or green light or check mark. Scenario 17: Using Paypal Given: You are asked to Pay for billing at checkout When: Scan Paypal QR code at the checkout counter, enter the amount need to pay after that select pay now Then: Purchase is approved Scenario 18: Accept Personal check Given: You are asked to Pay for billing at checkout When: You provide your check, Cashiers insert checks into a scanner or enter the information manually on the screen Then: Purchase is approved Scenario 19: Apple pay with debit card or Credit card. Given: You are asked to Pay for billing at checkout When: Store payment terminal accepts Apple Pay, unlock and get your iPhone close to the payment terminal if required enter pin or fingerprint. Then: Purchase is approved Scenario 20: Accept Cash Given: You are asked to Pay for billing at checkout When: Use bills or coins to pay the recipient from the cashier at checkout counter Then: Purchase is approved Scenario 21: Bill below $5 accept only cash Given: You are asked to Pay the bill which is below $5 at checkout When: Use bills or coins to pay the recipient from the cashier at checkout counter Then: Purchase is approved Scenario 22: Using Store Gift Card with Enough balance Given: You are asked to Pay the bill at checkout When: Use the same store gift card which has balance more than the bill amount Then: Transaction approved Scenario 23: Using Store Gift Card with low balance Given: You are asked to Pay the bill at checkout When: Use the same store gift card which has balance lower than the bill for remaining amount pay by Credit card/ Debit card/ Cash Then: Transaction Approved Scenario 24: Using Store Gift Card with no balance Given: You are asked to Pay the bill at checkout When: Use the same store gift card which has no balance Then: Transaction Declined Scenario 25: Using different store Gift Card Given: You are asked to Pay the bill at checkout When: Use the different store gift card got message” Card not accepted” Then: Transaction Declined Scenario 26: Using Expired Debit/Credit card Given: You are asked to Pay the bill at checkout When: Use the expired debit/ credit card got message “ Card Declined” Then: Transaction not approved Scenario 27: Return the product and get cash back to the Credit/Debit chip card Given: You are at the checkout counter to return the product with receipt When: Insert your Credit/Debit chip card into the chip enabled reader on the terminal Then: Cashier issue refund to inserted card for the product Scenario 28: Return the product and get cash back to the Credit/Debit swipe card Given: You are at the checkout counter to return the product with receipt When: Swipe your debit/credit card magnetic stripe on the swiping terminal Then: Cashier issue refund to swiped card for the product Scenario 29: Return the product and get cash Given: You are at the checkout counter to return the product with receipt When: you like get the refund by cash Then: Cashier will give back the money by bills and coins for the product Scenario 30: Exchange for a more expensive item pay remaining money from CC/DC chip Given: You are at the checkout counter to exchange the item with another item cost more When: Pay remaining money by Insert your Credit/Debit chip card into the chip enabled reader on the terminal Then: Transaction approved Scenario 31: Exchange for a more expensive item pay remaining money from CC/DC Swipe Given: You are at the checkout counter to exchange the item with another item cost more When: Pay remaining money by Swipe your debit/credit card magnetic stripe on the swiping terminal Then: Transaction approved Scenario 32: Exchange for a more expensive item pay remaining money by cash Given: You are at the checkout counter to exchange the item with another item cost more When: Pay remaining money by bills and coins Then: Cashier will give back approved transaction receipt Scenario 33: Exchange for a more expensive item pay remaining money from gift card Given: You are at the checkout counter to exchange the item with another item cost more When: Pay with your store gift card with enough balance. Then: Transaction Approved Scenario 34: Exchange less cost product receive remaining money from CC/DC chip Given: You are at the checkout counter to exchange less cost product When: Get your refund by Insert your Credit/Debit chip card into the chip enabled reader on the terminal Then: Purchase Approved Scenario 35: Exchange less cost product receive remaining money from CC/DC Swipe Given: You are at the checkout counter to exchange less cost product When: Get your refund by Swipe your debit/credit card magnetic stripe on the swiping terminal Then: Transaction Approved Scenario 36: Exchange less cost product receive remaining money to store gift card Given: You are at the checkout counter to exchange less cost product When: Get your refund to your store gift card. Then: Transaction Approved Scenario 36: Exchange less cost product receive remaining money by cash Given: You are at the checkout counter to exchange less cost product When: when you like to receive the money as bills and coins Then: Transaction Approved Scenario 37: Get cash back of $5 Given: You are at the checkout counter to pay your bill using debit card When: Payment terminal ask for cash back and give you options, Select $5 Then: Transaction approved, Cashier will give you $5 bill or Coins Scenario 38: Get cash back of $10 Given: You are at the checkout counter to pay your bill using debit card When: Payment terminal ask for cash back and give you options, Select $10 Then: Transaction approved, Cashier will give you $10 bill or Coins Scenario 39: Get cash back of selected amount Given: You are at the checkout counter to pay your bill using debit card When: Payment terminal ask for cash back and give you options, Select other and enter $20 in the payment terminal Then: Transaction approved, Cashier will give you $20 bill or Coins Scenario 40: Get cash back more than maximum amount Given: You are at the checkout counter to pay your bill using debit card When: Payment terminal ask for cash back and give you options, Select other and enter $100 in the payment terminal Then: Transaction declined Scenario 41: Skip cash back Given: You are at the checkout counter to pay your bill using debit card When: Payment terminal ask for cash back and give you options, Select “Skip” Then: Transaction Approved Scenario 42: Accept phone number as Reward card Given: You are at the checkout counter to pay your bill When: You have reward card linked to your phone number, enter your phone number at the payment terminal Then: Transaction approved, card accepted, Reward points for this purchase added to your account Scenario 43: Card doesn’t exist. Given: You are at the checkout counter to pay your bill When: You have reward card linked to your phone number, entered non registered phone number at the payment terminal Then: Reward card doesn’t exist. Scenario 44: Accept QR Code from store app as reward card Given: You are at the checkout counter to pay your bill When: You have membership as QR code in your mobile, scan your QR code in the terminal Then: Membership accepted, Reward points for this purchase added to your account Scenario 45: Swipe Reward card Given: You are at the checkout counter to pay your bill When: You have reward card, swipe reward card Then: Reward card accepted, Reward points for this purchase added to your account Scenario 46: Redeem reward point as gift card Given: You are at the checkout counter to pay your bill When: scan your reward card get gift card from cashier Then: Transaction Approved Scenario 46: Redeem reward point as cash Given: You are at the checkout counter to pay your bill When: Scan your reward card get Bills or coins from cashier Then: Transaction Approved Scenario 47: Accept printed/digital coupon. Given: You are at the checkout counter to pay your bill When: Scan your printed/ digital coupon Then: Coupon Accepted, discount applied to your purchase Scenario 48: Expired Coupon Given: You are at the checkout counter to pay your bill When: Scan your expired printed/ digital coupon Then: Expired coupon not accepted Scenario 49: Reload balance to your store card Given: You are at the checkout counter When: Insert your store card at the terminal and give cash that you want added to your card to the cashier Then: Store card reloaded successfully. Scenario 50: Price Match Given: You are at the checkout counter When: You want to ask cashier for price match the product from their competitor web store, if accepted. Then: Price Matched Approved




37 views0 comments

Recent Posts

See All

Headless Browser in Python

What is a headless browser? A headless browser can access any website but unlike normal browsers (which you currently use) nothing will appear on the screen. Everything is done on the backend side inv