Data-Driven Testing

3 years ago by Stephen Vance

It's common in test automation to create an exemplar test that you then parameterize to run across a wide selection of data permutations. This approach is known by many names, including parameterized tests, data-driven tests, or table-driven tests. You can now do this with mabl, making it easier to cover your whole range of app behaviors.

Training data-driven journeys and flows

Let's start with the training experience. First, you'll notice a new icon in the trainer to the left of the replay controls above the steps.

The Journey Variables button allows you to define variables that will be supplied externally.

The Journey Variables button allows you to define variables that will be supplied externally.

This button opens a table of variables that are supplied from outside of your journey along with their default values. The table is pre-populated with the system supplied values for the starting URL and, optionally, the plan credentials. You can add variables with values to this table. The values you enter here will be used as the default value any time the variable is otherwise undefined in the journey or reusable flows.

The journey variables table for values that might be supplied from outside of the journey.

The journey variables table for values that might be supplied from outside of the journey.

You can then use these variable just like any other in assertions, as input values, as URLs to visit, in template strings to generate other variables, or from within JavaScript steps.

Once you've saved your journey and run it, you will see these default values used in its execution. If you're happy with its execution, you can now make it data-driven.

Creating data tables for your tests

In the mabl UI, we have added a DataTables tab on the Configuration page. Create a new table whose headers are the names of the variables needed for your journey. (Yes, we will make this easier to do in the near future.) Fill in the values in as many rows as you want. If you keep your data in a spreadsheet today, you can also copy and paste your spreadsheet values into the table, and it will automatically expand in both directions to accept your pasted data. File upload is not yet available but is on the roadmap.

The new data tables in action.

The new data tables in action.

Save your data table, and it's ready for use.

Running journeys from a data table

To associate a data table with a journey, you need to edit a plan. The association is for the run of a particular journey in the plan, not for the journey in general.

For any journey in a plan, you can click the Add Parameter button, choose a parameter type of "DataTable" and select a data table for your journey.

Associating a data table with a journey when editing a plan.

Associating a data table with a journey when editing a plan.

As you edit the plan, you will see the message below the journeys update with the number of journey runs your plan will execute so that you can understand the cost impact of your configuration. A plan will execute a journey once for each row in the associated data table, or once for each journey without a data table, times the number of browsers configured for the plan.

As an example, if I have a plan configured to run Chrome and Firefox with three journeys, one with no data table, one with a data table with seven rows, and one with a data table with eleven rows, it will execute 2 x (1 + 7 + 11) = 2 x 19 = 38 journey runs each time it runs.

You also can see the selected browsers and number of runs in the plan summary.

A plan with multiple browsers and one journey.

A plan with multiple browsers and one journey.

A plan with multiple journeys and one browser.

A plan with multiple journeys and one browser.