A data generator (DG) returns a generated on-the-fly random value assigned to a variable with the same name, which is 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 web application by entering real-world business data. 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 AutoIncrement to generate sequential integers starting from the Min Value. After the Max Value is reached, the next integer is the Min Value. If uniqueness is required, make sure that Max Value will not be reached.
- 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 Constant Text property.
Use the Constant data generator in conjunction 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 DG type that will return the appropriate datatype.
4. Set When To Evaluate property to On Iteration or On Request
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 to use the same random value more than once.
Example: A web form 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
5. Configure remaining properties and give it 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:
When the Variable Picker is used to create a parameter, a properly formatted DG name reference is inserted automatically.
- No labels