BDD Cucumber Flow Diagram | How a BDD Cucumber Framework looks like

Опубликовано: 16 Май 2026
на канале: Viplove QA - SDET
3,674
9

BDD Cucumber Framework Explanation

1. What is BDD?

Behavior-Driven Development (BDD) is a software development approach that enhances collaboration among developers, testers, and business stakeholders by using simple, human-readable language to define application behavior.

2. What is Cucumber?

Cucumber is a popular BDD testing framework that allows writing test scenarios in Gherkin syntax (a plain English format). It bridges the gap between technical and non-technical team members by defining test cases in a structured manner.


---

3. Key Components of Cucumber BDD Framework

a. Feature File (.feature)

Contains test scenarios written in Gherkin syntax.

Uses keywords like Given, When, Then, And, But to describe test steps.


Example:

Feature: Login Functionality

Scenario: Successful login with valid credentials
Given User is on the login page
When User enters valid username and password
And Clicks on the login button
Then User should be redirected to the home page


---

b. Step Definition File

Maps each step in the feature file to actual Java (or Python, JavaScript, etc.) code.

Uses Cucumber annotations like @Given, @When, and @Then.


Example (Java - Selenium Cucumber):

import io.cucumber.java.en.*;

public class LoginSteps {

@Given("User is on the login page")
public void user_is_on_login_page() {
System.out.println("User navigates to login page");
}

@When("User enters valid username and password")
public void user_enters_credentials() {
System.out.println("User enters credentials");
}

@And("Clicks on the login button")
public void user_clicks_login() {
System.out.println("User clicks login button");
}

@Then("User should be redirected to the home page")
public void user_redirected_to_home() {
System.out.println("User is on home page");
}
}


---

c. Cucumber Runner Class

Executes the test cases using JUnit or TestNG.

Uses @CucumberOptions to specify paths and plugins.


Example (JUnit Runner in Java):

import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/resources/features",
glue = "stepDefinitions",
plugin = {"pretty", "html:target/cucumber-reports.html"},
monochrome = true
)
public class TestRunner {
}


4. Advantages of Cucumber BDD Framework

✅ Readable Scenarios – Easy for non-technical stakeholders to understand.
✅ Reusability – Common steps can be reused across multiple scenarios.
✅ Automation – Works with Selenium, REST Assured, Appium, etc.
✅ Integration – Supports CI/CD pipelines (Jenkins, Docker, GitHub Actions).