A Gherkin scenario can say that a traveler completes a flight and earns 550 points, but Cucumber cannot work out how to record the flight or check the points from those words alone. A step definition supplies the missing link: it matches a scenario step to executable code that performs an action or verifies an outcome. section 8.1 section 8.1.1
Turning a Given step into setup
For “Given Tara is a Standard Frequent Flyer member,” a Java @Given method can create a member named Tara with Standard status. The scenario states the business condition; the method establishes it for the test. section 8.4
Hard-coding every name or status creates duplicate definitions. A Cucumber Expression can match variable parts of a step and pass them as method parameters. For example, {word} can capture a name and a membership status, allowing one definition to serve related scenarios. Other expression types handle values such as integers and quoted strings. section 8.4.1
Listing 8.5 A step definition method with a parameter (in Java)
FrequentFlyerMember member;
@Given("{word} is a {word} Frequent Flyer member") #1
public void aFrequentFlyerMember(String name, String status) { #2
FrequentFlyerStatus statusLevel = FrequentFlyerCategory.valueOf(status); #3
member = FrequentFlyerMember.named(name).withStatus(statusLevel);
}
The Java listing shows the complete link: placeholders in the @Given pattern become arguments to a method that creates the member. section 8.4.1
Keep the step definition focused on translating business language into tasks and actions. Reusable tasks can sit beneath it, while a separate system-interactions layer handles details such as locating web elements or calling REST endpoints. A Screenplay-style definition, for instance, can map a sign-up step to tasks for signing up and verifying submission. section 9.3.1 section 14.3
Matching matters: if scenario wording changes without a corresponding definition, the step becomes undefined or pending rather than silently running the wrong code. Cucumber can suggest glue-code snippets for missing steps, and IDE integrations can help navigate to definitions and flag unmatched steps. Automate scenarios where doing so is worthwhile; the shared understanding captured in the scenario remains valuable even when automation is impractical. section 8.1.1 section 8.4.1 section 8.0

