Random variables in DataTables

In data-driven testing, you will typically want to test deterministic scenarios that verify the application under test always produces the same output given a specific set of inputs (e.g. 12 + 30 = 42). Nevertheless, there may also be situations in which you wish to test non-deterministic scenarios using random values. You can use random values with mabl datatables in the following way.

Your workflow

  1. Create a datatable and use random string templates as variable values.
  2. Create a test and associate the datatable with it
  3. Use the random variables with mabl Trainer just like any other variable in the datatable
  4. Run the test from the mabl app to validate everything works as expected

Datatable with random string templates

In the following datatable example, we have two variables and seven scenarios for each variable. The randomString variable is assigned a string template value for each scenario while the staticString variable has just static values.

mabl datatable using random string templates

mabl datatable using random string templates

When you run a test using the randomString variable from that datatable, mabl will assign a different random value to that variable according to the string template specified for the scenario.

Use the variables in the mabl Trainer

You can use random variables from a datatable in the same way as using any other datatable variable. Simply, associate the datatable with your test and use the mabl Trainer to enter the variable value into an input field in your application or assert against it.

If things are working correctly, mabl should input a random value generated based on the specified string template for the variable in the datatable.

Note that only the first datatable scenario variable values are used when replaying steps in the Trainer. Run the test as a part of a plan to see test results from all data-driven scenarios.

Running data-driven test scenarios as part of a plan.

Running data-driven test scenarios as part of a plan.

To verify that everything works, review the test results for one of the scenarios in the plan. You should see the generated random values in the run results.

Test results showing the generated random value for the randomString variable

Test results showing the generated random value for the randomString variable

Updated 3 months ago



Random variables in DataTables


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.