Careeroza
Real World Example
Food Delivery Order Flow in Gherkin
A food-delivery team (think Swiggy or Zomato) writes acceptance criteria for a new "schedule order" feature with the product manager. The same text becomes the automated check, so the PM can read the test results in the Cucumber report.
@regression @orders
Feature: Scheduled orders
@loggedIn
Scenario: Customer schedules dinner for later
Given the customer has "Paneer Butter Masala" from "Punjabi Dhaba" in the cart
And the restaurant is open from "11:00" to "23:00"
When the customer schedules the order for "20:30" today
Then the order status is "SCHEDULED"
And the checkout shows "Delivery at 8:30 PM"@When("the customer schedules the order for {string} today")
public void scheduleFor(String time) {
checkoutPage.chooseSchedule(LocalTime.parse(time));
orderConfirmation = checkoutPage.placeOrder();
}
@Then("the order status is {string}")
public void orderStatus(String expected) {
Assert.assertEquals(orderConfirmation.status(), expected);
}Example
mvn test -Dcucumber.filter.tags="@orders"Example output
1 Scenarios (1 passed) 5 Steps (5 passed) 0m9.611s
Lessons From Teams Using BDD
- Write steps in business language ("schedules the order"), never UI language ("clicks the blue button").
- Keep a shared step library; duplicated steps with different wording are the biggest maintenance cost.
- Step definitions call page objects. Cucumber does not replace POM, it sits on top of it.