Home > Automation Testing > Read data from CSV file using CSV Data set config in Jmeter

Read data from CSV file using CSV Data set config in Jmeter

For reading data from CSV file, JMeter provides a config element called CSV Data Set Config.
Below are the steps for configuring and executing CSV Data Set Config:
Step 1: Go to File -> Click on New. User will see a new Test Plan as shown in below image:

Image: New Test Plan
Image: New Test Plan

User needs to save the test plan with the desired name with .jmx extension as shown in the figure

Image: Save Test Plan

Step 2: Now, Add Thread Group to the test plan. In this example, 3 threads will be added to Thread Group.
Below image will show how test plan looks after adding Thread Group:

Image: Add Thread Group

Step 3: Now, Add CSV Data set config element to the test plan and configure as shown in the below screenshot.

Image: CSV Data set config setup

CSV file used in this example: data.csv

Details of the Fields present in CSV Data set config​

  • Filename: give name and location of the file which contains test data​
  • Variable names: Mention the parameter name which we want. ​
  • Delimiter: used to separate each record in the csv file.​
  • Allow quoted data: if true then data entered in double quotes can be used​
  • Recycle on EOF?: If number of threads are greater than data count then do you want to continue execution by start reading from beginning ?​
  • Stop thread on EOF?: If set “True”, reaching on EOF will cause the thread to be stopped.​
  • Sharing mode: Helps to define the sharing behaviour of CSV file. By default it is “All threads”. Three modes: All threads, Current Thread Group and Current Thread.​

Step 4: Next step after adding CSV Data set config element is to add HTTP request sampler to the test plan.
In the ‘Server Name or IP’ field add ‘societyhive.com’.
In the ‘Path’ field add ‘Home/LoginPopupLoginShow’.
Change HTTP Request method to ‘POST’
In the parameters section add two parameters with name: ‘Emailid’ and ‘Password’ and value as: ${username} and ${password}
Script should look like this once above fields are added.

Image: Configure Test Plan

Step 5: Now we will be adding Listener to the script. Listener will show result of the script run to the user. There are various types of Listeners. In this example we will analyze the result using ‘View Results Tree’ listener.

Below image will show how test plan looks once ‘View Results Tree’ is added.

Image: View Results Tree Listener

Step 6:Once script is executed output can be seen using the Listener added. Sample output will look like this:

Image: Sample Output in Tree Format

 

This Article is TAGGED in , . BOOKMARK THE permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">