Pertanyaan dan Jawaban Wawancara Paling Populer & Tes Online
Platform edukasi untuk persiapan wawancara, tes online, tutorial, dan latihan langsung

Bangun keterampilan dengan jalur belajar terfokus, tes simulasi, dan konten siap wawancara.

WithoutBook menghadirkan pertanyaan wawancara per subjek, tes latihan online, tutorial, dan panduan perbandingan dalam satu ruang belajar yang responsif.

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.

Hak Cipta © 2026, WithoutBook.