🥒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