Chapter 4Step Definitions: From the Outside

Now that you know how to use Gherkin to describe what you want your tests to do, the next task is to tell them how to do it. Whether you choose to drive your acceptance tests from Cucumber scenarios or simple JUnit tests, there’s no escaping the fact that you’re going to need to write some code eventually. It’s about that time.

Step definitions sit right on the boundary between the business’s domain and the programmer’s domain. You can write them in many JVM languages (for now we’ll show examples in Java) and their responsibility is to translate each plain-language step in your Gherkin scenarios into concrete actions in your code. As an example, take this step from the ATM scenario in the previous ...

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.