How to Generate Synthetic Test Data

When parameterizing tests with different variable values, you can Load Test Data from Spreadsheets or generate synthetic test data, or a combination of these sources.

Important: If you are using the debugger, click Stop to close the debugger before defining test data.

The scenario below walks you through the procedure of generating synthetic test data. The easiest approach is to insert a sample template and edit it for your needs; experienced users can also define functions and arguments manually.

Available Data Generator Functions

Synthetic Data Generator Functions work in the same way as advanced functions that you may be familiar with from Excel spreadsheets, such as DAYS() or CHOOSE().

The following functions are available:

Text Functions

generate new random strings, change the capitalization of a string, or tell you the length of a string.

List Functions

let you pick a random value from a list, or a substring from a string.

Identifier Functions

generate random but valid credit card numbers and globally unique identifiers.

Date and Time Functions

let you identify the day of the week or the name of the month, generate random dates and times, or generate dates and times within ranges.

Mathematical Functions

let you perform common mathematical operation (such as add, multiply, divide, modulo), convert bases, or generate random numbers.

Logical Functions

let you compare values and generate data according to custom conditions.

For the full list of all functions and their parameters, see Test Data Generator Functions.

Insert Synthetic Data Parameters From Examples

After you have recorded a test, you want to add synthetic test data. The provided example functions cover common cases such as personal data, financial data, date/time, text manipulation, JavaScript, JSON format, and Seed List examples such as street addresses or IP Addresses. You can edit and expand the inserted examples any time, as needed!

  1. Open a test and go to the Configuration tab.
  2. Click Test Data.
    The list of data parameters opens on the right side.
  3. Click the Plus button and select Create New Data Parameter From Example.
    The Add Data Parameter From Example window opens and displays common examples.
  4. Select an example category from the left column.
  5. Select an example variant where applicable.
    synth-test-data-from-example.png
  6. (Optional) Hover over an example line and click Preview parameter value to see an instance of generated data.
  7. Click Add to insert the example into your Test Data pane.
    BlazeMeter creates data parameters and initializes them with functions and values.

As described in How to Use Test Data, identify the data parameter that you want to use, click Copy Parameter Name to Clipboard, return to the test steps, and replace the hard-coded value with the pasted parameter. You can now run your test case as usual.

Some inserted example parameters rely on other parameters -- multi-column seed lists rely on an index parameter; an address is a concatenation of street and postal code parameters; a drivers license ID is a concatenation of name and date parameters; and so on. Before you edit or delete an example parameter, verify that no other parameter depends on it.

Inserting example parameters will not overwrite existing parameters of the same name. But if there are conflicting names, the inserted example may not work.

Scenario: Insert Synthetic Test Data Manually

In the following example scenario, you have recorded a Scriptless GUI Functional test case that types the hard-coded street name "Wall Street" into an address field. You now want to test this field with synthetically generated street names of varying lengths, randomly alternating with 50% null values using the percnull option.

You have familiarized yourself with the list of available Test Data Generator Functions and have chosen the randFromSeedlist() function with the "streetnames" parameter.

Follow these steps:

  1. Open a Scriptless GUI Functional Test and go to the Configuration tab.
  2. Click Test Data.
    The list of data parameters opens on the right side.
  3. Click the Plus button and click Create a new data parameter. Enter address as its name.
    test data parameters
  4. In the Parameter Value field, click the Functions menu. Hover over the function to view its documentation. Hover over and click the "i" icon to see a worked example, then click the arrow to return.
  5. Select a function and fill in its arguments.
    In this example, you have searched for a function related to lists and selected randFromSeedlist(). You want to use the "streetnames" parameter, column 1, and set the percnull option to 50% (to return an empty string in the half the test runs). Therefore you define the Parameter Value as: randFromSeedlist("streetnames", 1, 50)
    synth test data tooltip
  6. (Optional) Click Preview to view an example of generated test data.
    In our example, the ${address} preview may show a street name like "Quarry High Street" or an empty string with 50% probability.
    Click Preview a second time to return to the function definition.
  7. Click outside the field to save your changes.

As described in How to Use Test Data, identify the data parameter that you want to use, click Copy Parameter Name to Clipboard, return to the test step and replace the static value with the pasted parameter. In this example, you replace the hard-coded Text value "Wall Street" with ${address}. You can now run your test case as usual.

Scenario: Use CSV data as input to synthetically generate data

Sometimes when you load data from a static CSV file, it is missing relevant columns. You can add missing columns synthetically: BlazeMeter can populate, for example, an e-mail address column in the format firstname.lastname@domain.com based on the existing first and last name columns.

The following video shows how use CSV data as input to synthetic data generation functions:

Scenario: Replace CSV columns with dynamic test data

In this scenario, you have loaded data from a static CSV file, but you also need dynamic test data. For example, you can add a dynamic date of birth column that ensures valid dates with ages between 18 and 21 at the time the test runs. Rename the static birthdates column, create a new parameter named birthdates, and let BlazeMeter populate its values.

The following video shows how to make CSV files smarter by replacing static with dynamic data columns:

Scenario: Extend CSV rows with dynamic test data

In other scenarios, the CSV file suits your test case well and you want to keep using the static data. But for longer tests, you run out of rows. Instead of looping back to the beginning of the column and repeating values, you want to extend the column dynamically.

  1. Expand the Test Data pane and hover the mouse over the CSV entry.

  2. Click the More Actions menu and select Extend CSV File.

    The Extend CSV File window opens.

  3. Select a CSV column and click the pencil icon under Extend By Value to edit the field.

  4. Define the values that you want to generate synthetically.
    BlazeMeter suggests available test data generation functions and arguments.


  5. Click Save.

 

Tip: You can extend one column quickly by clicking the Extend icon and entering the data generator function and arguments. To reset the extension, click the same icon again.

 

Important: If you rename a column, BlazeMeter will treat it as if you deleted the column and added a new one: The data extension is deleted with its column and you need to recreate it.

 

Preview Generated Test Data

There are several ways how to pre- or review generated test data.

How to preview stand-alone values

test data preview parameter values

Click the Preview Parameter Value button next to a parameter to preview one instance of generated data. Click the button a second time to see the editable function again.

If a previewed parameter depends on another, random parameter, they are not synchronized in the stand-alone preview.
Example of two stand-alone values:

  • ${filename} = randText(10,15)
    Preview: "E36hvVLj4mri"
  • ${filenamewithsuffix} = ${filename}+".txt"
    Preview: "waFcYCk8TJI6Bh.txt"

How to preview synthetic values in context

test data iterations button

In the Test Data pane, click Iterations (for GUI Functional Tests) or Data Settings (for Performance Tests) to preview generated values. The Data Settings window opens and shows a table that lists the first hundred instances of test data generated for all parameters for a run, in context.

In context means that if a previewed parameter depends on another, randomized parameter, the two synthetic values are synchronized.
Here is an example of two dependent values that are synchronized in the preview:

  • ${filename} = randText(10,15)

    Preview: E36hvVLj4mri
  • ${filenamewithsuffix} = ${filename}+".txt"

    Preview: E36hvVLj4mri.txt

How to download test data for review

You can review the synthetic data that was generated after a test was run.

  1. Click Reports, and open the test report.
  2. Under Summary, click Show Test Data
  3. Review the test data used in this test.
  4. (Optionally) Download the test data.
  5. Click Close.