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.
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.
You will need to fill in at least three values in this screen:
- Filename: if your file is in the /bin directory, enter just the filename. If it’s somewhere else, use the full path to the file.
- Variable names: Define your column name mapping as a list of comma-separated strings. BlazeMeter uses these names as parameter names to refer to data columns. To skip a column, add an extra comma with no name.
Examples:- user,passwrd,cookielength,cookieneverexp
- lastname,firstname,,street,number,,
For a CSV file with six columns, this mapping lets you reference column 1,2,4,and 5 with the given parameter names, and you ignore column 3 and 6.
- Delimiter: A 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 names, enable this option. If the first row contains data, disable this option.
- Allow quoted data? If your column 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, otherwise it will be split into two columns.
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.

Now let’s switch to the Login request, 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.

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.
0 Comments