You can create data-driven variables at the test level as placeholders for variable values that you expect to be passed during a test run. Test data-driven variables are useful in the following situations:
- The test uses shared variables in a plan run.
- The test is configured to run against a DataTable
- Environment variables are passed to the test at runtime
Creating test data-driven variables
When creating data-driven variables, you have to assign a default value to be used in the event that the test doesn't receive that variable value from an external source, such as a DataTable. Default values are also helpful for training tests that rely on variables at runtime, such as environment variables or shared variables from previous tests.
Browser tests
You can create test-data driven variables in the mabl Trainer from the variables modal:
- Click on the {x} button in the bottom toolbar of the mabl Trainer.
- Select the option "Manage the variables in this test" to open the variables modal.
- Click on the Data-driven variables button.
The variables modal
- Click on the + New variable button.
- Enter a variable name and default value.
Managing test data-driven variables
- Click the Apply button to confirm your changes.
API tests
You can create data-driven variables in the API Test Editor by clicking on the Add row button in the Variables panel.
Click here for more information on adding test data-driven variables to API tests.
Using data-driven variables
You can use data-driven variables just like any other variable. For more information on using data-driven variables, check out one of the following resources:
Editing default variable values
On the test details page
- Click on the Edit variables button in the Data-driven variables section.
- Update the default values.
- Click Save.
Editing data-driven variables from the test details page
In the mabl Trainer
For browser tests, you can also update and delete test data-driven variables in the mabl Trainer:
- Click on the {x} button in the bottom toolbar of the mabl Trainer.
- Select the option "Manage the variables in this test" to open the variables modal.
- Click on the Data-driven variables button to start editing your test data-driven variables.
- To update, modify the name or value fields.
- To delete, click on the trash icon. You can also bulk-delete variables by selecting the variable checkbox and clicking the Delete Selected button.
- Click on the Apply button to save your changes.
In the API Test Editor
Use the Variables panel in the API Test Editor to update and delete test data-driven variables.
Identify flow data-driven variables
You can distinguish test data-driven variables from flow data-driven variables on the test details page in the Data-driven variables section:
- Flow data-driven variables: If a data-driven variable includes a link to a flow, it means that the variable is a flow data-driven variable. Clicking on the name of the flow takes you to the flow details page.
- Test data-driven variables: If a data-driven variable does not include a link to a flow, then the variable is a test data-driven variable.
Editing data-driven variables from the Flow Details page