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…
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 so please excuse the naïve mistakes. But he will definitely improve with chapters he writes. """
Here, the highlighted text is the Doc String that we will be passing to the Step Definitions.
Save and run the Feature file, and copy and paste...