Using Doc Strings to parse big data as one chunk

Now let's consider a situation where we have to specify a lot of text in multiple lines (not in the shape of a table)—something like a few lines from a blog or a book. So, how do we handle this in Step Definitions? This is called passing Doc Strings in test Steps. Based on what we have covered until now, we can use regular expressions; but this is helpful for the first line only, and the text in all the other lines will be missed. In this recipe, let's see how to handle this situation.

How to do it…

  1. Let's consider the following Step in our Feature file for this exercise:
    Given a book named "cucumber cookbook" with following body
      """
      Title – Cucumber cookbook
     Author of this book is first time writer ...

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.