Training data-driven tests

Supplying the variables in a test

You can add data-driven variables to your tests via the {x} variables icon in the bottom toolbar of the mabl Trainer. To create a variable, click on Create and select to set the value of the variable from a data source, which will be the associated DataTable.

You can also create and mange your data-driven variables by clicking on Manage, instead of Create, which will display all data-driven variables for the test with their default values and an option to add more such variables. All environment and system-generated variables are also displayed on that screen in read-only mode to prevent naming conflicts with data-driven variables you create.

Manage variables for data-driven testing.Manage variables for data-driven testing.

Manage variables for data-driven testing.

When creating data-driven variables, you must assign a default value that will be used in case there isn't any value passed on to the test for that variable from an external source such as a DataTable.

You can use data-driven variables, just like any other variable as for example:

  • in assertions
  • as input values
  • as URL's to visit
  • in template strings to generate other variables
  • in custom JavaScript steps


Editing default variable values

When you go to manage variables in the Trainer, you can update the 'default' values of the data-driven variables. Please, replay the test in the Trainer to make sure everything works with the updated defaults.


Data-driven variables

In order to ensure that your variables are being properly overridden in data-driven tests, you want to make sure that you supply a list of all the variables your test uses and their default values.

When you save the test, you will see all data-driven variables used in that test on the test details page as shown in the image below.

Test details with data-driven variables.Test details with data-driven variables.

Test details with data-driven variables.

You can easily create a DataTable table based on those variables by clicking the GENERATE DATATABLE button, which will take you to the DataTable editing screen where you can add different scenarios to test.

Alternatively, you may want to first create a DataTable and then associate it with the test.

Did this page help you?