With data-driven variables, you can configure your tests to pass in dynamic variable values at run time, resulting in more flexible, scalable tests. This article describes the different types of data-driven variables in mabl and outlines the order of precedence if multiple values for the same variable are passed to the test at run time.
Types of data-driven variables
mabl supports the following types of data-driven variables:
- DataTable scenarios
- Shared variables
- Environment variables
- Test data-driven variables
- Flow data-driven variables
DataTable scenarios
When a test is associated with a DataTable, it generates one run for each scenario, or row, of the DataTable. Each DataTable scenario passes a set of variable values to the test.
Shared variables
When tests run in a plan sequentially or in stages, you can configure an earlier test to share values such as authentication tokens or test data with a subsequent test in the plan execution.
Environment variables
When variables are defined at the environment level, they are passed to the test when it runs in that specific environment.
Test data-driven variables
Test data-driven variables serve as placeholders for values that you expect to be passed to the test run from a DataTable scenario, shared variable, or environment variable. If no data-driven variables are passed to the test during execution, the test uses the default value of the test- data-driven variable.
Flow data-driven variables
When a flow uses a variable that was created outside of the flow, mabl automatically creates a flow data-driven variable. This variable serves as a placeholder for a value that you expect to be passed to the flow from a different source, such as a prior test step, environment variable, or DataTable scenario. If you import the flow into a different test where this variable isn’t defined, the flow uses the default value of the flow data-driven variable.
Order of precedence for data-driven variables
If multiple values are passed to a test for the same variable, the following order takes precedence:
- DataTable scenario
- Shared variables
- Values stored with the environment
- Test data-driven variables (default values)
- Flow data-driven variables (default values)
The value coming from the DataTable scenario will overwrite other values.
Data-driven variables and valid expressions
In data-driven testing, you typically want to test deterministic scenarios that verify the application under test always produces the same output given a specific set of inputs. Nevertheless, it is possible to use random values.
The following valid expressions may be used for data-driven variables that run in browser tests:
- Macros
- Faker data
- Mathematical expressions
API tests do not support these valid expressions, but they do support Postman dynamic variables.