0% Complete


This lesson will help you understand mabl's Data-driven Testing functionality. 

Before taking this lesson

Make sure you are comfortable with the following lessons:

  • mabl App Intro
  • mabl Trainer Intro

Learning Objectives

  • How to create data-driven tests
  • How a data-driven test works
  • Understand when data-driven testing is to be used

Lesson Outline

  • Creating data tables for your tests
  • Create data-driven variable
  • Running data-driven tests

Why is this important?

In test automation, there are often cases where you might have multiple data sets for which you need to run the same tests. In mabl, you should be able to do this using data-driven testing or DDT. This is the process of loading data that is external to your functional tests to strengthen and extend your automated test cases.

Advantages of data-driven testing

  • Reusability: Any test script can be written and re-executed hundreds or thousands of times, with different inputs each time.
  • Versatility: A data-driven test is usually associated with a single test or procedure, but can be used in several test cases.
  • Efficiency: Data-driven tests can generate test scripts with less code
  • Separation of logic: Data-driven tests allow for the clean distinction of test case logic from the actual test data.
  • Stronger test coverage: You can continually change the input test data and cover a broad scenario of inputs.

Getting started

Creating data-driven variables

  • Click on the {x} variables icon in the bottom toolbar of the mabl Trainer
  • Click on Manage, which will display all data-driven variables for the test with their default values and an option to add more such 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

Generating DataTable from data-driven variables

Once you have created the data-driven variables and saved the test, you can create a data table from it by following the below steps:

  1. On the test details page, click on the generate data table button
  2. It will redirect you to a new page
  3. Provide a name to the data table and add a scenario name (optional)
  4. Click on the Save button and you are done!

Assigning scenario names to your DataTable

A scenario is a set of values, a specific row in a data table to be precise, that are passed a test as part of data-driven testing.

  1. To assign a scenario name to your data-table, click on the "Configurations" tab on the left menubar and then click on “DataTables”
  2. Click on the desired data-table to edit it
  3. Provide a scenario name and save it
  4. To add a new scenario, click on the “Add Scenario” button, provide a value and save

Creating DataTables for your tests

  1. To create a new data-table, click on the "Configurations" tab on the left menubar and then click on “DataTables”
  2. You can either upload an existing CSV file or create a new data table from scratch
  3. To create a new data table from scratch, click on the "Create Table" button
  4. Fill in the values with as many rows and columns as you'd like, by clicking the "Add scenario" or "Add variable" buttons
  5. Save the DataTable and it will be ready for use

Associating A new test with an existing Data table

  1. Create a new test from either the main dashboard page or via the "New" button
  2. Toggle "Show advanced options" on and scroll to the "DataTables" section
  3. Choose one or more DataTables from the list of existing DataTables
  4. Select the specific DataTable you'd like to train with using the "DataTable for training..." dropdown
  5. Click the "Create test" button to start training

Associating existing tests and DataTables

  1. Navigate to the test you wish to associate with a DataTable, and click on the "Update Info" button
  2. In the modal, select a DataTable for the test in the "DataTables" dropdown
  3. Click the save button at the bottom of the modal, and you're all done!

Running tests with a data table

  • If you wish to run a test with all the scenarios in the data table, there are two options
    • Navigate to the Plans page and click on the Run Test button near the test name.
    • Navigate to the Tests page, click on the Run Test button, toggle on the Run datatable scenarios option, and click on the Start button.

Checking the variable value used during the cloud run

  1. Navigate to the Results page, filter by the test name and click on results link corresponding to the desired run or navigate to the Tests page, filter by the test name, click on the run history and click on results link corresponding to the desired run
  2. On the test summary, click on view under variables
  3. You should be able to see the data driven variables and their values


Viewing scenario names

You can find the scenario names on the: 

  • Plan details page

  • Test run summary

  • Results page

Some points to note when running tests using data tables

  • Ensure that data-driven values have a default value
  • If your test is supposed to use multiple data tables and you have enabled the train with the DataTable option, the data-driven variables will be created only for the selected table. For others, you would have to manually create them
  • Running a test from the Plans page or enabling the Run datatable scenarios option will trigger a run for each scenario in your data table
  • While creating a data table by uploading an external CSV file, ensure that the first row has headers that represent the variable names in mabl


What did we learn?

  • What is data-driven testing?
  • How can you test scenarios with multiple data sets?


Was this helpful?

Take this 2 minute survey to let us know how we can make mablU better!