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 Test::Unit scripts, 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. They’re written in Ruby,[11] and their responsibility is to translate each plain-language step in your Gherkin scenarios into concrete actions in Ruby code. As an example, take this step from the ATM scenario in the previous chapter:

 
Given ​I have $100 in my Account ...

Get The Cucumber 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.