Using CSV DATA SET CONFIG

JMETER: CSV DATA SET CONFIG

If you need to test web-site, the first thing you should do is login operation. JMeter has an element that allows you to read different parameters from text file. It is “CSV Data Set Config” which is used to read lines from a file, and split them into variables.

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

CSV Data Set Config
Figure 1

I guess that if you read this article, it is no sense to explain how to use “HTTP Request Defaults”, “HTTP Request”. Also I hope you already know that “Aggregate Report” and “View Results Tree” are used for gathering results. Look at the Figure 2.

CSV Data Set Config fields
Figure 2

You’ll need to fill in at least 3 values on this screen:

  • Filename: if your file is in the /bin directory, this can be just 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: comma is the default delimiter, but if your file uses tabs this is the place to say so.

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

I have 4 variables for passing to Login request. They are “user”,”passwrd”,”cookielength”,”cookieneverexp”. And look at the Figure 3 to see what I have in csv_data.txt.

How to fill csv_data.txt
Figure 3

Let’s switch to Login request, Figure 4.

HTTP Post request
Figure 4

You see table with variables. There are 4 variables, the same quantity as in CSV Data Set Config, but the 4th variable is invisible due to JMeter issue. As you can notice, value field has the same name as variable in csv data set. Construction ${….} means that is variable but not absolute value.

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

HTTP Post request results
Figure 5

It is worth mentioning that every CSV Data Set Config is visible to all Thread Groups by default. If you need to use separate CSV Data Set Config for every Thread, you create a number of data files that you need and in every CSV Data Set Config set “Sharing mode” to “Current Thread”


Want to take your JMeter testing to the next level?

Run your own JMeter scripts in the cloud (JMeter-as-a-service) with up to 100,000 concurrent users, real time reporting and nice looking graphs :)

BlazeMeter

provides a performance testing solution that's 100% compatible with Apache JMeter™

Feedback and Knowledge Base