Now that you know the anatomy of a Data-Driven test, here’s a trick that simplifies the process of Data Driven testing using Cucumber. Cucumber inherently supports Data Driven testing by the use of the Scenario Outline and Examples sectionIt is with these keywords that Cucumber allows for easy Data Driven testing to be completed where no changes need to be made to the Ruby File.

Before getting to the details of how Scenario Outline and Examples work together to help the tester, below is the example script that we will be referencing, a simple calculator check:

As you can see it is a simple Cucumber test where the feature and scenario are defined. Below we will be using Scenario Outline and Examples to tell what data we want to be testing:

Now the test will run with the two different set of values, completing two runs.  Instead of hardcoding the test data, variables are defined in the Examples section and used in Scenario Outline section.

The Examples section is a table where each argument variable represents a column in the table, separated by “|”. Each line below the header represents an individual run of the test case with the respective data. As a result if there are 5 lines below the header in the Examples table, the script will run 5 times with its respective data.