Multiple Test Data using Data table in Cucumber

When we have multiple test data to pass in a single step of a feature file, one way is to pass multiple parameters and another way is to use Data Tables.

Data Tables is a data structure provided by cucumber. It helps you to get data from feature files to Step Definitions. Its a bridge between feature file and Step Definition to pass values to the parameters.

Data can be passed as a large number of data, as One-Dimensional data, as two-dimensional data and also in the form of key-value pair.

Using Data Table as a List:

Let us consider a scenario: I want to Sign up to Facebook ( where we have to pass data like Firstname, Surname, Mobile Number, Password, Date Of Birth, Gender.

In the feature file, these data parameters are passed using a separator (|)

Let us see the feature file below where we are covering signup to facebook.

Feature File:

Step Definition File:

In the above scenario, the DataTable is sending the list of data in the one-dimensional form. We received the data in a list of String and passed in order.

Using Data Table in key-value pair:

Let us consider a scenario: I want to login to Facebook ( with username and password. We will pass the username and password as parameters using Data Tables.

Feature File:

Step Definition File:

In the above example, the values are passed as the key-value format. Username –, and Password – password. While receiving the data we converted the DataTable data structure into the Map using a method called testData.asMap(String.class, String.class). Argument mention the data type.

For any questions, queries or comments feel free to write to us at or Happy Learning 🙂

Saurabh Dhingra

About the Author

Saurabh Dhingra

Follow Saurabh Dhingra: