Run JMeter Test by Sending Unique Value to Each Thread In JMeter
How is the CSV Data Set Config Element used in JMeter?
The CSV Data Set Config element is used to send the unique values to each user in JMeter test by utilizing a CSV data file. The CSV Data Set Config element reads the data from the CSV file and splits them into variables, and these variables are used in the test plan to send unique data to each user during test execution.
When we use the CSV Data Set Config element it gives us the flexibility to make the values dynamic which is helpful in simulating the real world scenarios closely.
Suppose you are running the test with 100 users on the login functionality of an E-Commerce website then executing the test with the same credentials for all 100 users does not reflect a real-world scenario instead of that we can create a CSV file with unique credentials for all 100 users and then we can integrate that file in our JMeter with the help of CSV Data Set Config element.
Advantages of using CSV Data Set Config element
Parameterization – It helps us in testing with different data sets instead of hardcoding the values. We can use a CSV data file to store the data and data Set Config element to read and split those data into variables and this way we can make our test more dynamic.
Realistic Approach – While doing Performance Testing Data Set Config element helps us in simulating real-world scenarios closely, because with the use of the Data Set Config element, we can send different data to the test plan.
Easy Maintenance – If we want to change the input data, we can directly do that by updating the CSV file without touching the test. This makes the test easier to maintain.
Reusability – Once we create a test that uses the Data Set Config element but later if we want to test the same scenario with a different data set then we just need to change the CSV file or just need to update the data in the existing CSV file.
Scalability – When we do Performance Testing with 100 users and we use the Data Set Config element it helps us in sending the unique values to each user and this helps us in simulating a wide range of user behaviors which is like a real-world user.
How to Add Data Set Config element in JMeter Test?
Right-click on the thread group
Hover the cursor to “Add”.
Hover the cursor to “Config Element” and select CSV Data Set Config.
How to Configure CSV File in CSV Data Set Config Element?
To read the CSV file into JMeter test adjustments must be made in the CSV Data Set Config Element.
Filename – If the CSV data file is present in the
bin
folder of Apache JMeter then we can directly add the file name with an extension and if the CSV data file is present somewhere else then we can add thefile path
in the File Name field.Variable Names – In this, we add the variable's name, column-wise which we have given in
.CSV
file by separating them with a comma.Delimiter – Delimiter in CSV Data Set Config Element is used to differentiate each record in the CSV file. A comma is the default Delimiter but in the file, if we are using a tab then we need to define the same here.
Allow Quoted Data – You can place values within double quotes
("")
, which enables them to hold a delimiter if this option is enabled.Recycle on EOF – If you want to use a CSV file only for one iteration then youcan set it
False
or else if you want to use a CSV file for multiple iterations then set itTrue
.Stop Thread on EOF – If you want to stop the test after reading the whole CSV file then set it
True
or else set itFalse
.Sharing Mode – In sharing mode, JMeter gives us 3 options.
All Thread – The CSV file is shared with all threads and this is the default option.
Current Thread Group – Each file is opened for every thread group, in which elements appear.
Current Thread - For every thread, a separate file is opened.
Conclusion
CSV Data Set Config element in JMeter plays an important role in enhancing the performance testing. By using the CSV Data Set Config element we can parameterize the test and send the different data to each user by making it dynamic instead of hardcoding the values in the test and this helps us in simulating and understanding the real user behavior.
Subscribe to my newsletter
Read articles from Gulshan Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Gulshan Kumar
Gulshan Kumar
As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman. I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.