Skip to main content

Combining Doc Strings and Scenario Outlines in Cucumber

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

    Given I am on the home page
    And I follow "Contact us" link

  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>.

      | email                     | team    | order  | user   |
      | | Support | O21234 | Tarun  |
      |    | 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.

Submitted by tgoswami on August 30, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.