Javatpoint Logo
Javatpoint Logo

What is the Data Table in Cucumber?

Data tables are used when we need to test numerous input parameters of a web application. For example, the registration form of the new user involves several parameters to test, so for this, we can use the data table.

Let's understand the data table with an instance of a registration form of javatpoint.com, which is a web application. For this registration form, we are going to create a typical feature file, and later we will create a feature file with data table to recognize the difference between them.

The registration form contains the following parameters:

  • User Name
  • Email
  • Password
  • Confirm Password
  • Birth-date
  • Gender
  • Phone Number

Feature file to test the feature "User Registration."

Feature: New user registration.
Scenario: Verification of successful registration when the inputs are correct. 
Given user on the user registration page
 When user enters a valid user name 
And valid e-mail address 
And valid password 
And valid confirmation password 
And valid Birth-date 
And valid Gender 
And valid phone number 
Thenuser registration should be successful 

In the above feature file, we can see that it looks a bit complex at first glance due to using "And" multiple times. So, to reduce such type of complexity, we can use "Data Table."

Data table involves a set of input parameters, and these parameters are provided to a single tag such as GIVEN, WHEN, or THEN.

Let's create the above feature file with the data table, and see how it will look:

Given the user on the user registration page.
When user enter invalid data on the page
| Fields|| Values|
| First Name            | User Name           |
| Last Name             | User Last Name      |
| Email Address         | someone@gmail.com    |
| Re-enter Email Address | someone@gmail.com   |
| Password              |PASSWORD|
| Birth-date              | 02|
Then the user registration should be successful.

In the above feature file, we can see that all parameters of the registration form have been organized in a simple and recognizable manner.






Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA