Use datatable

Applies to CucumberStudio Cloud, and to Enterprise ver. 3.3 - 3.5.6.0. Last updated on November 17, 2023

Introduction

Sometimes, you may want to test a behaviour of a feature but for different combination of values:

Do login with [email protected] credentials
Do logout
Check that user [email protected] is logged out
 
Do login with [email protected] credentials
Do logout
Check that user [email protected] is logged out

As you can see, if you want to write the same test for other languages, you will have to copy-paste this scenario for each set of values (in the example, the language and the welcoming message)

The datatable is a feature that allow you to execute a single scenario with different values. It avoids duplication of the steps by having separately editable data.

If you are using Gherkin syntax, the datatable is the equivalent of scenario examples. However, unlike regular Gherkin, you can have only one datatable for a scenario in CucumberStudio.

Edit a datatable

Graphic version
Edit datatable: graphic version

Click the image to enlarge it.

Each column represents a datatable parameter. The name of the column is the name of the parameter.

Each row represents a dataset (a set of values) and its cells should not be empty.

Raw version

Using the datatable raw version editor, it is possible to write the examples in Gherkin syntax by editing, or copying and pasting its content:

Edit datatable: raw version

The raw version editor supports also CSV formatted data. Just paste the CSV content in the editor and it will be automatically formatted.

Use data in steps

Steps are action words

When adding a new step, type the datatable parameter name between double quotation marks:

If you want to use datatable values in an already written step, just fill the parameters fields with the datatable parameter name:

If the step already exists and does not have a parameter, you can add one by renaming it. To do so, type the parameter name between double quotation marks and confirm the renaming. Then, write down the datatable column name in the parameter field:

Steps are action/result

When using action/result, you can use the datatable parameter by using the syntax: ${column_name}

Steps using free text parameter/step datatable

You can use the datatable values in free text parameters and step datatable using the syntax: ${column_name}

Tests generation

When viewing tests, you can switch from a dataset to another and visualize the scenario with the values of the selected one:

See Generate tests section for more information on the relationship between scenario, datatable and test.

See Also

Best practices for scenario writing

Highlight search results