JMeter, an open source load testing tool, has an element that allows you to use external data sets in a CSV format. This element is called the “CSV Data Set Config”. The CSV Data Set Config is used to read lines from a file and to split them into variables.  

The following article elaborates in the detail on the how to use this element when creating your performance testing scripts in JMeter.

If you already know how to use the CSV Data Set in JMeter but wish to run your performance tests in BlazeMeter, please refer to this article, "CSV File Upload", which will elaborate on that procedure. Let's get started.

First I will create a test plan. The Test Plan contains one Thread Group. The Thread Group consists of “HTTP Request Defaults”, “CSV Data Set Config” and “HTTP Request”. Also, I will add an “Aggregate Report” and a “View Results Tree”. See Figure 1.


Figure 1

I assume that if you are reading this article, there is no need to explain how to use the “HTTP Request Defaults” and “HTTP Request” elements. Also, I hope you already know that “Aggregate Report” and “View Results Tree” are listeners that are used for gathering results.

So let's look at the CSV Data Set Config configuration at Figure 2.


Figure 2

You will need to fill in at least three values in this screen:

  • Filename: if your file is in the /bin directory, this can just be the filename. If it’s somewhere else, use the full path to the file.
  • Variable names: this is the equivalent to a “column name” in a spreadsheet.
  • Delimiter: a comma is the default delimiter, but if your file uses tabs, this is the place to mention that.

The other fields are optional but they may be useful to you. Read all about them from the JMeter CSV Data Set Config user manual.

I have four variables that are sent with the Login request. They are “user”, ”passwrd”, ”cookielength”, ”cookieneverexp”. Look at the Figure 3 to see what I have in csv_data.txt.

How to fill csv_data.txt
Figure 3

Now let’s switch to the Login request, Figure 4.


Figure 4

In the request, you can see the table with the variables. There are four variables, the same quantity as in 'CSV Data Set Config'. As you can notice, the value field has the same name as variable in the 'CSV Data Set'. The construction ${….} means that this is a variable and not an absolute value.

Now, if I run the test-plan, JMeter will parse 'csv_data.txt' and change ${passwd}, ${user}, etc., with their values. The results are displayed in Figure 5.

HTTP Post request results
Figure 5

It's worth mentioning that every 'CSV Data Set Config' is visible to all Thread Groups by default. If you need to use separate the 'CSV Data Set Config' elements for each Thread, create the number of data files that you need, and set the 'CSV Data Set Config' element from “Sharing mode” to “Current Thread”. Learn more from this blog post, "CSV Data Set Config in Sharing Mode - Made Easy".


Learn more JMeter! View our free webinar "How to Create Advanced Load Testing Scenarios with JMeter" or get free JMeter training from our JMeter Academy.

BlazeMeter enhances JMeter features and abilities. Request a demo and start testing now.



Have more questions? Submit a request


Article is closed for comments.