Updated February 21, 2023
Introduction to JMeter CSV Data Set Config
JMeter is a performance and load testing tool for applications and websites. It is open-source and holds an element that enables the user to work on the external dataset in a CSV format. It is known as “CSV data set config.” It reads the lines from a file and divides them into variables. It is easier to implement than the string from file and CSVread options. It is designed to manage higher dimensional data and is useful for testing unique and random values. This article briefly discusses the data set configuration in JMeter CSV.
JMeter CSV data set config overview
The CSV data set config in JMeter is used to view the lines from the given file and can be divided into variables per the requirement. It is also used to test random and unique values. Generating unique random values on run-time is costly in terms of memory and CPU. So the user can create the data before the test. If required, the random data from any file can be implied to combine with a run-time parameter to develop a distinct set of standard values from every execution. For example, concatenation implementation is cheaper than generating the values at every execution.
Create JMeter CSV data set config
The creation of the JMeter CSV data set config is explained in the below steps. Then, the user can execute the test using the data from the pre-defined CSV file and read along with it while executing.
- Generate a few of the usernames and passwords on their own similar to the data in the CSV file. For example, let tom, sam, joe, and Jim be the username and pas$$, groovy, scala, and secret be the passwords. The comma is a delimiter to separate the values in the CSV files. Finally, save the file with the appropriate name in the same location as the test plan.
- In the test plan, create a dataset config by following the steps, test plan -> add -> config element -> CSV data set config. Give the name of your CSV file created in the above step. Provide the variable name in the concerned field; every variable is equal to a single column in the CSV. These variables will be helpful for future reference. Ensure to separate the values using a comma
- Replace the constant data in the login request by fetching the variables from the CSV file.
- In the thread group field, give the number of threads to eight. It should be equal to the count of users in the CSV file. Execute the test. Every request uses distinct data from the created CSV file to log in.
Using JMeter CSV data set config
Provide the filename which should be read. For example, the test plan used in the same location with a .jmx file format should be given input in the CSV file. However, if the CSV file has a different location than the file that belongs to the test plan, then the user should only give the name of the absolute path of the CSV file.
In Windows, it should be C:\desktop\JMeter\name of the file.csv
In Mac, it should be /Users /user /Desktop /name of the file.csv
The dot represents the current folder in the test plan. The \ can be used in Windows, Linux, and Mac.
The CSV file is a plain text notepad, so the user can add an extension to it like .txt instead of .csv. But ensure that the format is not changed.
Encoding the file is used to read it irrespective of any platform. The default encoding is applied to read the file and helps the user in all types of data files like double-byte other languages. The user can save the file in Unicode or UTF-8 to ensure the data is not segregated in the window. But in Windows, the default encoding is scripted in ANSI and JMeter when encoding or reading this file will create a problem by breaking the data. To avoid this, enter the same encoding of the file in the required File encoding field under the data set config.
If the Variable name is null, then the first line in the file is read and interpreted with the same column name list. The variables can be quoted by double-quotes and can be differentiated by delimiters.
The delimiter is used to separate the records in the file; sometimes, a semicolon or tab can be used. For example, if users need to add a price to the file, they can change the delimiter and set it in the JMeter.
Enable the quoted data, which allows only the delimiter values. If the data has space, it comprises delimiters, and the value is in the downline. So it is solved when double quotes are used. So set True to the double-quotes.
Recycle on the End of the File; by default, it should be set to true. The options stop thread on EOF should be set to false.
Sharing modes are enabled in all threads, current thread groups, and current threads. All thread in the file is shared between every available thread. It doesn’t work on the request received on thread groups, even if it has occurred in loops. So every request view only one line CSV, assuming that all the data set is at the same level within the thread group.
Hence, the data set config values can be easily implemented in JMeter to view every file thread. It has a unique feature in the current thread group; every file is viewed once for every thread group where the element appears. If a new thread group is initiated, it reads the file from the beginning and assumes that all the data set is present within the same level of the thread group. In the current thread, every file is viewed separately for every user; it is viewed separately for every thread, which signifies that the user has read the file again from the beginning. Only the loop present in the thread will read the next line.
This is a guide to JMeter CSV Data Set Config. Here we discuss the data set configuration in JMeter CSV in brief with an overview. You may also look at the following articles to learn more –