Using Test Data in JMeter Performance Tests

JMeter scripts can load test data either from external CSV files or from BlazeMeter Data Entities. If your test configuration is in another format, see Using Test Data in Taurus Scripts.

JMeter test configurations have a script element that lets you read lines from an external file and assign them as values to variables in your script. This element is called the CSV Data Set Config. In addition to BlazeMeter's own test data integration, BlazeMeter supports uploaded JMeter scripts with existing CSV Data Set Config .

A Data Entity is a container to store, manage, and share test data in BlazeMeter. BlazeMeter Data Entities support any combination of the following data sources to provide test data to a Performance test:

You can use one or combine multiple of these data sources in a test, as needed.

How Do I Reference CSV Files?

Before uploading an existing test configurations to BlazeMeter, edit the JMX and make sure to reference your CSV files using relative paths, as shown here. Next, upload existing CSV files or create new Data Entities in BlazeMeter to extend or replace CSV files. When you create a Data Entity in BlazeMeter, BlazeMeter creates a corresponding CSV file that you could download and reference from your JMeter script.

Data Source

Relative Path

A Data Entity created in BlazeMeter named "My test data"

"My_test_data.csv"

A CSV file my_test_data.csv uploaded to BlazeMeter and attached to a test

"my_test_data.csv"

A CSV file our_test_data.csv uploaded to BlazeMeter's Shared Folder our_shared_folder

"our_shared_folder/our_test_data.csv"

To identify the implicit file name of the Data Entity, click the info button next to the Data Entity's name. The implicit data file names and their contents are also included in the report log.
identify the path to a data entity as csv file

Create Data Entities in BlazeMeter

The BlazeMeter test data integration is quite flexible: You can start by creating a Data Entity in BlazeMeter and later edit the JMeter file to use it. Or, you can upload existing JMX and CSV files together, and expand the test data in BlazeMeter later. Or, you can record a JMeter test using the Chrome Recorder Extension, and add data entities and CSV files later.

  1. Go to the BlazeMeter Performance tab.
  2. Open an existing Performance Test.
  3. Click Test Data and click the Ellipsis button to add a data entity.
    The Test Data pane in BlazeMeter is visible only after you have uploaded or recorded a test script.
  4. Click the small plus button to add one or more data parameters to the data entity.
    For more information about data parameters, see How to Use Test Data.
  5. (Optional) Download the data entity as a CSV file for external use.

 

Prepare the Test Configuration File

BlazeMeter uses the first row of data as parameter names to refer to the columns in the CSV file. If the first row of the CSV file does not contain column names, provide a comma-separated list of variable names in the test configuration.

Open the JMX script in JMeter and edit the following fields in the CSV Data Set Configuration.

  • File Name:
    Provide the relative file path of the file attached in BlazeMeter.
    Example:
    File Name: My_test_data.csv
  • Variable names:
    If the first row of the CVS contains column headers, leave this field empty.
    If the first row contains data, define column name mappings here. To skip a column in the mapping, add an extra comma with no name.
    Example:
    Variable names: lastname,firstname,,street,number,,
  • Delimiter:
    Comma is the default delimiter, but if your file uses tabs, enter \t here.
  • Ignore first line?
    If the first row of the CSV file contains column headers, enable this option.
    If the first row contains data, disable this option.
  • Allow quoted data?
    If your values can contain commas, and you also use commas as delimiters, then allow quoted values.
    Example: If a value can be "123 Main street, Springfield", make sure to surround it by double quotes and enable this option, otherwise it will be split into two columns.

JMeter, csv data set

Example:

The file "mydata.csv" has six columns and no column headings. You want to reference address data in column 1, 2, 4, and 5, and ignore column 3 and 6. Therefore, you declare the following in the Variable names field:

lastname,firstname,,street,number,,

In a test script, you are now able to reference the values of column 1 as ${lastname}, column 2 as ${firstname}, column 4 as ${street}, and so on.

Link the Test Data to the Test Configuration

  1. Log on to BlazeMeter and go to the Performance tab.
  2. Upload the prepared JMeter file.
  3. Click Test Data to open the Test Data pane.
  4. If the script has unresolved references and variable names in its CSV Data Set Config, BlazeMeter now lists the missing files.
    Choose from the following options:
    1. Click Upload CSV File to attach the missing test data in CSV format.
    2. Click Suggest Data to generate synthetic test data for the defined variable names.
    3. Click Load Data Entity to load existing shared test data from the workspace.
      For more information, see CSV Data Set Config in the JMeter user manual.

Make sure to create and define all parameters that are referenced in your script before running the test.

How many files can I add in a BlazeMeter test ?

You can add any files you need to be used as part of your script during your test.  

What is the maximum file size?

Individual files up to 50MB can be uploaded. If a file is larger, please zip it. BlazeMeter will unzip it prior to script execution. 

Preview Test Data

Previewing your test data is helpful when you are combining data from multiple sources, or generating synthetic test data, so you can view values in context.

  1. Open a Performance Test with test data attached.
  2. Verify that at least one data parameter is defined to be able to generate the data preview.
  3. Click Test Data, Data Settings.
    The Test Data Settings window opens and shows the data preview.

 

Related Tasks