Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Cucumber Cookbook

You're reading from   Cucumber Cookbook Over 35 hands-on recipes to efficiently master the art of behaviour-driven development using Cucumber-JVM

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781785286001
Length 162 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Shankar Garg Shankar Garg
Author Profile Icon Shankar Garg
Shankar Garg
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Cucumber Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Writing Feature Files FREE CHAPTER 2. Creating Step Definitions 3. Enabling Fixtures 4. Configuring Cucumber 5. Running Cucumber 6. Building Cucumber Frameworks Index

Implementing data table diffs to compare tables


Consider a situation where you need to verify an application response that is in the form of Table to another Data Table that we are sending in Feature file. This kind of verification is very common when we are testing REST services.

Based on what we have learned so far, we will break the Data Table down in the Feature file into a List of Lists, and then we will verify each element of those Lists with expected Lists (which we got after breaking the table). Let's understand how we can do this in an easier way.

How to do it…

  1. For this recipe, consider the following Scenario:

      Scenario: Table Diff
        Given user send a get request to "localhost:8080/e"
        Then user gets following response
          | username | age |
          | sham     | 25  |
          | ram      | 26  |
  2. Now save the Feature file. After adding the following code to suggestions, this is how our Step Definitions will look:

    @Given("^user send a get request to \"(.*?)\"$")
    public void user_send_a_get_request_to...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images