Parameterization

Parameterization is a technique in BDD (Behavior Driven Development) using Cucumber to make your test scenarios data-driven — meaning, the same scenario steps can be reused with different sets of data.


🎯 Why Use Parameterization?

  • Avoid duplication of scenarios

  • Make test cases scalable and maintainable

  • Improve test coverage with different inputs

  • Easily map real-world behavior with test cases

Syntax:

Scenario: Search product on eBay

Given I am on the eBay homepage

When I search for "<product>"

Then I should see results with at least <count> items


Example:

Scenario: Search product on eBay

Given I am on the eBay homepage

When I search for "iphone13"

Then I should see results with at least 1500 items


Steps File


@When("I search for {string}")

public void i_search_for(String productName) {

// Use productName in your Selenium logic

}


@Then("I should see results with at least {int} items")

public void i_should_see_results_with_at_least_items(int expectedCount) {

// Use expectedCount for validation

}