With data-driven testing you can parameterize your tests across different inputs that are loaded at runtime. When you are creating and editing these tests, you can use test data-driven variables as placeholders. Test data-driven variables assign a default value for training. At runtime, mabl overrides the default value with the real variable from the DataTable scenario, shared variable, or environment.
This article explains how to work with test data-driven variables, including how to:
- Create test data-driven variables
- Edit default values
- Delete test data-driven variables
- Convert test data-driven variables into a DataTable
Create test data-driven variables
When you create test data-driven variables, assign a default value to use while training and editing the test.
Make sure the variable name matches exactly with the name of the variable that will be passed in at runtime, whether it’s a shared variable or a value from a DataTable scenario. Variable names are case sensitive.
Passing a value from another test?
Create a test data-driven variable in the receiving test with the exact same name. The default value is just a stand-in for training. See sharing variables between tests for more details.
Browser and mobile tests
For browser and mobile tests, take the following steps in the mabl Trainer:
- Click on the {x} button in the bottom toolbar of the mabl Trainer.
- Select the option “Manage variables”.
- Click on the Data-driven variables button.
- Add the test data-driven variable with a default value.
- Save your changes.
You can now use the test data-driven variable like you would any other variable in the mabl Trainer.
Managing test data-driven variables
API tests
To create test data-driven variables for an API test, launch the API Test Editor and take the following steps:
- Expand the variables panel.
- Add the test data-driven variable with a default value.
- Save your changes.
You can now use the test data-driven variable like you would any other variable in the API Test Editor.
Location of the variables panel
Edit default values
To edit the default value of a test data-driven variable, click on the Edit variables button on the test details page. Update the default value and save.
Editing data-driven variables from the test details page
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. Click on the name of the flow to view or update the flow data-driven variable from the flow details page.
Delete test data-driven variables
Test data-driven variables can only be deleted from the Trainer or the API Test Editor.
For browser and mobile tests, delete it in the mabl Trainer:
- Click on the {x} button in the bottom toolbar of the mabl Trainer.
- Select the option “Manage variables”.
- Click on the Data-driven variables button.
- Delete the test data-driven variable.
- Save your changes.
For API tests, delete it in the API Test Editor:
- Expand the variables panel.
- Delete the test data-driven variable.
- Save your changes.
Convert test data-driven variables into a DataTable
To convert your test data-driven variables into a DataTable, click on the Generate DataTable button on the test details page.
On the new DataTable page, give the DataTable a name and name the first scenario. Add any additional configurations as needed, such as additional scenarios or resource group settings.
When you save the DataTable, it is automatically associated with the test. Moving forward, you can launch the Trainer or API Test Editor and associate the session with a DataTable for future test edits.