A data generator (DG) returns a generated on-the-fly random value assigned to a variable with the same name used to parameterize requests. Depending on the DG type, the value can be random or systematic. DG can be used for creating streams of emulated business data of different types, which can be included in the HTTP load stream. It allows to more realistically mimic physical users interacting with a web application by entering real-world business data. In addition, it helps to avoid creating large test datasets manually.

A data generator type determines what random value will be returned: Integer, Double, Date/Time, GUID, or Text.

The following DG types are supported.  

  • Integer - Returns an integer between the Min Value and Max Value. 
    • Set Type to Auto-Increment to generate sequential integers. See below for more on auto-increment data generators.
    • Set Type to Random to generate random integers between the Min Value and Max Value. The uniqueness of the random numbers is not guaranteed.   
  • Double - Returns a double-precision point number between the Min Value and Max Value.
  • DateTime- Returns a date-time object between the Min Value and Max Value.
  • GUID - Returns a new GUID.
  • Text - Returns a set of characters with a length between Min Length and Max Length. 
  • Constant - Returns a constant text defined in the Constant Text property.

    Note

    Use the Constant data generator with other source variables to add a constant prefix or suffix to dynamic data.


How to create a Data Generator

  1. Select the Data Generators node on the Test Workflow Tree.
  2. Click Create a New Data Generator to bring up the generator dialog.
  3. Select the DG type that will return the appropriate data type.
  4. Set When To Evaluate property to On-iteration, On-request or On-read
    1. On-iteration: If the same data generator is used in multiple parameters, it will generate the same value for the entire iteration.
    2. On-request: A data generator will generate a new value on every use.
    3. On-read: If the same data generator is used in more than one parameter, it will generate a new value (for every iteration) for every recorded value it replaces. 


Tip: Evaluate on iteration

Set the When To Evaluate property to On-iteration to generate a new value on every iteration (default).  In this case, the random values persist throughout the iteration for every VU. That allows using the same random value more than once.

Example: A webform requires entering an email address created by a data generator twice for verification purposes. In this case, set When To Evaluate property to On-iteration to avoid failing due to entry mismatch.

Alternatively, set it to On-request to generate a new value on every request.

Tip: Evaluate on read

Set the When To Evaluate property to On-read to generate a new random value to replace every unique recorded value. However, two identical recorded values will be replaced by the same data generator value on a single VU-Iteration.

For example, if you parameterize 4 recorded values "aaa", "bbb", "ccc" and "aaa" in your test case , then you can get corresponding data generator values "123", "456", "789", "123" on-iteration 1 and 987", "654", "321", "987" on-iteration 2. Note that the 1st and the 4th random values are the same (within one VU-iteration) because the 1st and the 4th recorded values are the same.

An alternative way to create the same type of parameterization is to create 3 data generators with the When To Evaluate property set to On-iteration: DG_aaa to parameterize 1st and 4th the recorded value, DG_bbb parameterize 2nd recorded value, and DG_ccc to parameterize 3rd recorded value.

However, n-iteration substantially simplifies parameterization since you can use a single data generator. It's beneficial when you need to parameterize multiple recorded values.

Note:

When a data generator with the When To Evaluate property set to On-iteration or On-read is inside a loop object like Loop or Do...While with the Increment the index for iteration-bound datasets property set to yes, a new value is generated on every loop iteration.

5. Configure the remaining properties and give them a unique name. It will appear in the Variable Picker when you create parameters. Use the Format String property to format the generator output.

6. Click Verify to test the return value.

7. Click Save & Close.



When the DG is used to parameterize a request, it is referred to by its name surrounded by the brackets, for example:  {{MyRndInteger}}.

When the Variable Picker is used to create a parameter, a properly formatted DG name reference is inserted automatically. 

Concatenation Expression Parameters 

Data generators can create parameters based on expressions of two constant substrings with a random value between them. In Concatenate Expression property, enter "{0}" surrounded by prefix and suffix substrings. 

For example, if a data generator Is configured to generate a random integer between 0-100, and its Concatenate Expression property Is set to id ="{0}", then such data generator will render values like id="72" or id ="31".

Auto-increment data generators

Integer data generators can be marked as auto-increment to generate sequential integers starting from the Min Value. After the Max Value is reached, the next integer is the Min Value. 

Note:

If uniqueness is required, make sure that the Max Value will not be reached.


Auto-increment data generators can have the following scopes that can be set using the Auto-increment scope property:

  • All-VUs to keep a global auto-increment counter shared by all VUs
  • Per-VU to keep a separate auto-increment counter for every VU

Persisting the value between test runs

Using the All-VUs scope, you can persist the current value between test runs. Set the Persist auto-increment value across test runs? property to Yes to continue the auto-increment value from the previous test run.



  • No labels