Sometimes, you may want to test a behaviour of a feature but for different combination of values:
Check that user email@example.com is logged out
Do login with firstname.lastname@example.org credentials
Check that user email@example.com 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
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.
Using the datatable raw version editor, it is possible to write the examples in Gherkin syntax by editing, or copying and pasting its content:
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:
Steps using free text parameter/step datatable
You can use the datatable values in free text parameters and step datatable using the syntax:
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.