Transforming Data Tables to parse the test data

In the previous chapter, we covered how Data Tables can be used to send large sets of data to a single Step. Now let's understand how to handle Data Tables in Step Definitions in this recipe.

How to do it…

  1. Let's assume we are writing Step Definitions for the following Scenario:
    Scenario: Existing user Verification
        Given user is displayed login screen
        Then we verify following user exists
          | Name    | Email           |
          | Shankar | sgarg@email.com |
          | Ram     | ram@email.com   |
          | Sham    | sham@email.org  |
  2. Now run the Feature file, and copy paste the Cucumber Step Definitions suggestions in the LoginSteps.java class. These are the additional Steps in LoginSteps.java:
    @Then("^we verify following user exists$") public void we_verify_following_user_exists( ...

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