When you run a test with a DataTable, you can validate the reliability of your application across a range of different scenarios. Whether you want to test out one scenario locally or run multiple scenarios in parallel in a plan run, mabl offers several options to suit your needs.
This article explains how to run tests with DataTable scenarios:
Results from a test run with a DataTable
In order to run tests with DataTables, you need to associate the DataTable to the test first.
Ad hoc runs
Mabl supports ad-hoc runs with DataTable scenarios both locally and in the cloud.
Local runs
In the mabl CLI, you can trigger local runs with DataTable scenarios using the mabl tests run
command:
- To run one scenario, use the
--scenario-id
option with the appropriate scenario ID - To run all scenarios sequentially, use the
--data-table-id
option with the appropriate DataTable ID
In the mabl Desktop App, you can only trigger a local run for one DataTable scenario at a time:
- Navigate to the test you wish to run.
- Click on the Run test button.
- In the Local run tab, toggle on "Run DataTable scenarios" and select the DataTable and the scenario.
- Click on the Start run button.
Cloud runs
In the mabl CLI, you can trigger cloud runs with DataTable scenarios using the mabl tests run-cloud
command:
- To run one scenario, use the
--scenario-id
option with the appropriate scenario ID - To run all scenarios in parallel, use the
--data-table-id
option with the appropriate DataTable ID
You can also trigger ad hoc cloud runs with one or all DataTable scenarios from the mabl Desktop App:
- Navigate to the test you wish to run.
- Click on the Run test button.
- In the Cloud run tab, toggle on "Run DataTable scenarios" and select the DataTable. You may run all scenarios or select a specific scenario for a cloud run.
- Click on the Start run button.
When a DataTable is selected, the Start run button updates to reflect the number of runs (scenarios) that will be triggered. When running all scenarios in the cloud, tests run in parallel.
Plan runs
If a plan includes a test that is associated with a DataTable, the plan will run all DataTable scenarios associated with the test. If the test is in a plan stage that runs concurrently, the scenarios will run in parallel. If the test is in a plan stage that runs sequentially, each DataTable scenario will run one at a time.
There are two options for limiting the number of scenarios that run during a plan run:
Ignoring DataTables
To prevent a test from using a DataTable for a specific plan, take the following steps:
- Navigate to the plan you wish to edit.
- Click on the pencil icon to open the edit plan page.
- Find the specific test in the Tests section.
- Click the pencil icon to open up the options panel.
Editing the test settings in the edit plan page
- Click on the + Add parameter button.
- Set the Type field to "Ignore DataTables." This parameter ensures the test does not use any associated DataTables. Instead, the test will run just once with its default data-driven variables.
- Click Done to confirm your settings.
- Click Save.
Setting one specific DataTable for a test
If a test that runs in a plan is associated with multiple DataTables, you can force the test to run with a specific DataTable by taking the following steps:
- Navigate to the plan that you wish to edit.
- Click on the pencil icon to open the edit plan page.
- Find the specific test in the Tests section.
- Click the pencil icon to open up the options panel.
- Click on the + Add parameter button.
- Set the Type field to "DataTable."
- Set the DataTable field to the specific DataTable you wish to use for this plan run.
Selecting a specific DataTable for a plan
- Click Done to confirm your settings.
- Click Save.
Plans with DataTables and multiple browsers
If a plan is configured to run on multiple browsers and includes tests that are associated with DataTables, the plan will run those tests once for each DataTable scenario multiplied by the number of browsers configured.
For example, if a plan is configured to run on Chrome and Firefox and includes a test associated with a DataTable that has seven scenarios, the plan run will execute 14 runs just for the test associated with the DataTable.