What We Just Learned

It’s useful to think of a step definition as being a special kind of method. Unlike a regular method, whose name has to match exactly, a step definition can be invoked by any step that matches its regular expression. Because regular expressions can contain wildcards, this means you have the flexibility to make the Gherkin steps nice and readable, while keeping your Java step definition code clean and free of duplication.

  • Step definitions provide a mapping from the Gherkin scenarios’ plain-language descriptions of user actions into Java code, which simulates those actions.

  • Step definitions are registered with Cucumber by using @Given, @When, @Then, or one of the aliases for your spoken language.

  • Step definitions use ...

Get The Cucumber for Java Book now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.