Doc Strings allows you to specify a larger piece of text that could not fit on a single line and If we want to repeat all the steps of a Scenario again and again for different sets of data, we implement Scenario Outline.
You can combine your Doc String with Scenario Outline in several situations.
Consider a situation when you have to test email applications with different username and detail inside message body. In that case you need to combine Doc String with Scenario Outline.
Feature: Test Misc Functionality Background: Given I am on the home page And I follow "Contact us" link @contactus Scenario Outline: Fill in Email form When I fill in "input[id='email']" with "<email>" And I fill in "textarea[id='message']" with: """ Dear <team>, Please share the status of my <order>. Thanks, <user> """ Examples: | email | team | order | user | | email@example.com | Support | O21234 | Tarun | | firstname.lastname@example.org | Sales | O31234 | Manish |
In above case, two emails we are sending to two different user with different details. In Doc String section (""") email, team, order and user will be replaced email, team, order and user data in Example section.