Using CSV data in JMeter

on 2 March 2023 CI, CLOUD, DEVOPS, JMETER, LOAD_TESTING, PERFORMANCE with 0 comments
Csv icons created by Freepik - Flaticon

Create a CSV file

First, create a CSV file with the data that you want to use in your JMeter test. The first row of the CSV file should contain the column names, and each subsequent row should contain the corresponding data.
For example, if you want to test a login functionality of a website, you can create a CSV file with two columns, “username” and “password”, and each row representing a set of login credentials.

Add CSV Data Set Config element

Next, add a CSV Data Set Config element to your JMeter test plan. This element can be found under the “Config Element” section in the JMeter GUI.

Configure the CSV Data Set Config element

In the CSV Data Set Config element, specify the path to the CSV file that you created earlier in the “Filename” field. You can also specify other settings such as delimiter and variable names. Note that you should put the name of the file and put this file in the same folder as the JMX file. Otherwise you will need to use a JMeter property.

Use variables in your test plan

Now you can use the variables defined in the CSV file in your JMeter test plan. For example, you can use the ${username} and ${password} variables in an HTTP Request Sampler to simulate a login request.

To use the variables, simply enclose them in curly braces, like ${variable_name}.

Run your test plan

Finally, run your JMeter test plan and JMeter will automatically pick up the data from the CSV file and use it in your test.
That’s it ! You have now successfully used a CSV file in your JMeter test plan.

About UbikLoadPack:

Other links: