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.
- Create a DataTable and use random string templates as variable values.
- Create a test and associate the DataTable with it
- Use the random variables with mabl Trainer just like any other variable in the DataTable
- Run the test from the mabl app to validate everything works as expected
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.
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.
You can use random variables from a DataTable in the same way as using any other DataTable variable. 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.
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.
Updated 3 months ago