Creating Step Definitions

Without thinking too much about what they mean, let’s just copy and paste the snippets from Cucumber’s last output into a new Java file. Let’s create a new folder to keep our step definitions in:

 
$ ​mkdir step_definitions

Now create a Java file called CheckoutSteps.java in step_definitions. Cucumber won’t mind what you call it as long as it’s a Java file, but this is a good name to use. Open it in your text editor and enter the following class definition:

first_taste/04/step_definitions/CheckoutSteps.java
 
package​ step_definitions;
 
 
import​ cucumber.api.java.en.*;
 
import​ cucumber.api.PendingException;
 
 
public​ ​class​ CheckoutSteps {
 
}

Now paste in those snippets:

first_taste/04/step_definitions/CheckoutSteps.java ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.