DTM Data Generator is a powerful tool for test database population, data scrambling, and load testing. The variables support adds an easy way to share settings between data generation rules for individual columns of data. Only Professional and Enterprise editions of the software support this feature.
The variable is a named scalar value. In most cases, it is a string value that can be converted to a number, date or time if necessary.
There are three sources of variable's value: constants, database query, and test data generation engine expression (also known as "pattern"). In the first case, the user should provide immediate value. In the second he or she provides the program with SQL query. At the last one, it is an expression that will be discussed below.
It is important to understand that the program uses the first value of the first result set's row in the second case. It ignores other fetched data values.
Also, there are two levels of variables: local and global. The local variable can be used in the single project but the global one is available in any project. By performance reason, it is not recommended to use more than 25-30 global variables.
The local (project level) variable name starts from '#' sign like #FROM, #TO. The '@' means global variable. The prefix before variable name is mandatory but we do not recommend to use the same name for local and global variables.
Where can the variable be used? The variable is acceptable in a few fill method properties directly as well as in "by pattern fill method" i.e. in the data generation engine calls.
Sample 1. Minimum and maximum value for random integer sequence. Let's define two variables #FROM and #TO as shown in the screenshot:
Now we can use the variables in the "Random value" fill method ad a low and high borders for the column:
Sample 2. The step value for incremental fill method. For this sample we define variable #STEP with value 3 and use it as shown at the screenshot:
Sample 3. The data generation engine $Vars call. This example explains how to create the variable as an engine call and how to use in tin another engine call. At the first step, we'll create global variable @V2TO10 with a random number between 2 and 10. To create it, select "Pattern" type of variable and use $Rint(2,10) call to generate mentioned value:
At the second step we will use "Pattern" will method and include created variable to engine call: $$($Vars(@V2TO10)*$Vars(@V2TO10)):
This call takes variable values twice and multiplies results. We'll get squares of values between 2 and 10: 4, 9, 16, 25...
Please note that the program calculates the variable's value (pattern or database query) once between rule execution. This execution way allows users to access the same variable value from all rules.
For example, we want to use same value as a high border of the range for 12 columns generation. Without variables, we have to change properties for 12 fill methods manually. With the variable, we'll change it only once.