Book Image

Cucumber Cookbook

By : Shankar Garg
Book Image

Cucumber Cookbook

By: Shankar Garg

Overview of this book

Table of Contents (13 chapters)
Cucumber Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating your first Step Definitions file


Now let's assume you are an automation developer and you have to implement automated test cases for a Feature file. The next Step in this direction would be to write the Step Definitions for this Feature file. So, how do we write Step Definitions in a Cucumber project? Let's see how to do this in this recipe.

How to do it…

The easiest way to create Step Definitions is to let Cucumber take care of it. The Steps are as follows:

  1. Here is the Feature file used in our previous chapter. Let's use this Feature file to create our first Step Definitions:

    Feature: login Page
      In order to test login page
      As a Registered user
      I want to specify the login conditions
    
      Scenario: checking pre-condition, action and results
        Given user is on Application landing page
        When user clicks Sign in button
        Then user is on login screen
  2. When you save the Feature file and run (either via Eclipse or via a Terminal), Cucumber is going to give errors for the missing Step...