Skip to content
  • ZipCode Api
  • Blog
  • About RedLine13
RedLine13
RedLine13
Primary Navigation Menu
Menu
  • Start Testing
  • Demo
  • Pricing
  • JMeter
  • Partners
  • Docs
    • Documentation Home
    • AWS Set Up for load testing
    • AWS Approval for Large Tests
    • PHP, NodeJS, Python Load Tests
    • Scalability
    • Jenkins Plugin Setup
    • Premium Features
    • Knowledge Base

Parameterizing JMeter Tests from a CSV Data Source

By: David Koziel

Parameterizing JMeter Tests from a CSV Data Source

When designing a load test, it is a common goal to emulate real-world requests to the best extent possible. It is easy to generate thousands of requests with JMeter. However, there is often a need to generate many different requests. Using parameterization, this is a straightforward task. In this brief post, we will illustrate the steps of parameterizing your JMeter tests from a CSV data source.

Step 1.

The first element we want to add to our test plan is a “CSV Data Set Config”. We can add this directly at the root level of the Test Plan:

Adding the “CSV Data Set Config” element to our test plan
Adding the “CSV Data Set Config” element to our test plan.

Step 2.

Once added, we can configure the CSV data source. The filename is the only field that is usually required. However, if our CSV file does not contain a header row, we can specify a comma-delimited list of column names. Correspondingly, the column names in either case will become variable names when referenced within our test.

Configuration settings for our sample CSV data source
Configuration settings for our sample CSV data source.

Step 3.

The next logical step would be to use data fields from our CSV file to create variable requests. JMeter has a special convention for this – ${variable}. (This syntax is explained here in the JMeter documentation under “User Variables”.) An example of such usage in an “HTTP Request” element would be as follows:

Example of a JMeter “HTTP Request” element configured for User Variables
Example of a JMeter “HTTP Request” element configured for User Variables.

In the above screenshot we have the request parameter “itemCode” configured to the value contained in “columnX” within our CSV file. For each iteration where this request is called, it will read the value from sequential lines within that file.

Step 4.

Once we complete the test plan, it is time to upload it to RedLine13. However, since our test plan is dependent on a CSV file, we’ll have to upload that as well. The CSV file (in this case “Sample CSV File.csv”) is added to the test run as an “Extra File”:

Uploading a CSV file for use with a JMeter test

Running the Test

So, what happens now when we run our test? If we configured everything properly as above, we should see requests come through with parameters set to match what is contained within our CSV file. Here is an example of what we can expect to see with a “View Results Tree” listener configured:

Request parameters are sourced from the specified CSV file
Request parameters are sourced from the specified CSV file.

Each sequential request that references the CSV-mapped variable will read from the subsequent line. If you execute more requests than you have lines in your CSV file, JMeter will cycle to the beginning of the file and reuse values again.


Advanced Data Driven Tests

Like what you see and ready to move to the next level with data driven JMeter testing on RedLine13?  We have a feature on our platform that lets you split records in CSV across your load agents which you can read about here.  Another advanced concept we have written about is using Groovy scripting for data driven testing using Excel files.


Ready to try this example out for yourself? We offer a full-featured free trial that you can sign up for and start testing today!

2021-12-09
Previous Post: RedLine13 Customer Review
Next Post: Free Load Test Trial

Recent Posts

  • Guest Post – IoT Load Testing
  • Load Testing Users in India
  • Load Testing in India
  • Troubleshooting Common Issues with Selenium Tests on RedLine13
  • Extracting Metadata from Load Generator Instances

Related

  • Load Testing Users in India
  • Guest Post – IoT Load Testing
  • Guest Post: Load Testing with Locust and JMeter on RedLine13
  • Run Your RedLine13 Load Tests from Hyderabad, Jakarta and Melbourne
  • Load Testing in India
  • Selenium Basics for Load Testing
  • Pitfalls of Selenium Load Testing
  • Troubleshooting Common Issues with Selenium Tests on RedLine13
  • Extracting Metadata from Load Generator Instances
  • Case Study: iCIMS, The Talent Acquisition Software Experts

© RedLine13, LLC | Privacy Policy | Contract
Contact Us: info@redline13.com

Designed using Responsive Brix. Powered by WordPress.