Questions et réponses d'entretien les plus demandées et tests en ligne
Plateforme d'apprentissage pour la preparation aux entretiens, les tests en ligne, les tutoriels et la pratique en direct

Developpez vos competences grace a des parcours cibles, des tests blancs et un contenu pret pour l'entretien.

WithoutBook rassemble des questions d'entretien par sujet, des tests pratiques en ligne, des tutoriels et des guides de comparaison dans un espace d'apprentissage reactif.

Chapter 4

Step Definitions, Glue Code, Parameterization, and Mapping Gherkin to Automation

Learn how human-readable scenarios are connected to executable code and why step design quality matters.

Inside this chapter

  1. What Step Definitions Do
  2. Basic Example
  3. Parameters and Reusability
  4. Step Design Advice

Series navigation

Study the chapters in order for the clearest path from beginner BDD concepts to advanced automation architecture. Use the navigation at the bottom of each page to move through the full tutorial series.

Tutorial Home

Chapter 4

What Step Definitions Do

Step definitions are the code methods that bind Gherkin steps to automation logic. They are the bridge between the language of behavior and the language of implementation. Each matching step definition interprets the scenario step and runs the corresponding code.

Chapter 4

Basic Example

@Given("the user is on the login page")
public void user_is_on_login_page() {
    driver.get("https://example.com/login");
}

@When("the user enters valid credentials")
public void user_enters_valid_credentials() {
    loginPage.login("student@example.com", "secret");
}

This is where good architecture matters. The step definition should usually call page objects or service helpers rather than contain all low-level logic inline.

Chapter 4

Parameters and Reusability

@When("the user searches for {string}")
public void user_searches_for(String keyword) {
    searchPage.search(keyword);
}

Parameterized steps reduce duplication and make features more expressive. Advanced teams balance reuse with readability so that steps stay meaningful instead of becoming generic and confusing.

Chapter 4

Step Design Advice

Strong step definitions are business-readable, cohesive, and thin. Weak step definitions leak too many implementation details or become giant methods with mixed responsibilities. Keep the behavior description high-level, and push technical details into helper layers.

Copyright © 2026, WithoutBook.