๐ฅ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
Was this helpful?