๐Ÿฅ’BDD

๐Ÿ“š BDD

BDD stands for Behavior Driven Development.

๐Ÿ’ฌ Gherkin Language

  • Tests are written in simple English-like language called Gherkin.

  • Uses keywords like Given, When, Then to structure test scenarios.

  • Creates living documentation of system behavior.

๐Ÿฅ’ Cucumber Framework

  • Cucumber implements BDD principles.

  • Tests written in Gherkin are executed by Cucumber.

  • Step definitions map Gherkin steps to code.

๐Ÿ‘ Benefits

  • โœ… Improved collaboration between teams

  • ๐Ÿ“– Documentation integrated with tests

  • โš™๏ธ Ties code to business behavior

๐Ÿฅ’ BDD Example for CNBC

//CNBC Login Feature
Feature: CNBC Login

  Scenario: Valid Login
    Given I am on the CNBC login page
    When I enter username as "john123"
    And I enter password as "pass123"
    And I click on login button
    Then I should see homepage
//Step Definitions  

@Given("I am on the CNBC login page")
public void launchLoginPage(){
  //Code to launch login page
}

@When("I enter username as {string}")
public void enterUsername(String username){
  //Code to enter username 
}

//Other steps defined similarly

Last updated