Logo

dev-resources.site

for different kinds of informations.

How to use CSV file for parameterization in JMeter

Published at
1/21/2023
Categories
jmeter
performancemeasurement
loadtesting
tutorial
Author
rusydy
Author
6 person written this
rusydy
open
How to use CSV file for parameterization in JMeter

Parameterization is the process of creating multiple test data sets for a single or multiple users in a test script. This is useful when you want to test the performance of your application with different data sets. For example, you want to test the performance of your application with 100 users, each with a different data set. In this case, you can use parameterization to create 100 users with different data sets.

In this article, we will use Wikipedia as an example. We will test the performance of Wikipedia with 100 users, each with a different search keyword (city names). The search keyword will be read from a CSV file.

The test scenario is as follows: We will conduct a load test on the search functionality of Wikipedia with 100 users, each with a different search keyword (city names). The search keyword will be read from a CSV file. In this scenario, the Jmeter test script will have two HTTP requests. The first request is to open the Wikipedia home page, and the second request is to search for a city name.

Here are the steps to set up this test:

  • Open JMeter and create a new Test Plan.
  • Right-click on the Test Plan and select Add > Threads (Users) > Thread Group. Set the number of threads (users) to 100.

Step 2

  • Right-click on the Thread Group and select Add > Sampler > HTTP Request. Enter the base URL of Wikipedia, which is https://en.wikipedia.org/. Leave the Method as "GET". This request will open the Wikipedia home page.

Step 3

  • Right-click on the Thread Group and select Add > Config Element > CSV Data Set Config. Enter the filename of the CSV file that contains the list of city names. Set the Variable Names to "city".

Step 4

  • Right-click on the Thread Group and select Add > Sampler > HTTP Request. Enter the base URL of Wikipedia, which is https://en.wikipedia.org/. Set the path to "/wiki/" and leave the Method as "GET". In the "Send Parameters With the Request" section, add a parameter with the name "search" and value "${city}". This request will search for the city name on the Wikipedia page.

Step 5

  • Start the test by clicking on the "Start" button. JMeter will now read the data from the CSV file and use it to open the Wikipedia home page and search for the city name for each user. On real-world scenario, we will use non GUI mode to run the test.

To run the test in non-GUI mode, you will need to use the command line. Here are the steps to run the test:

  1. Open a command prompt or terminal window.
  2. Navigate to the directory where JMeter is installed.
  3. Type the following command:

    jmeter -n -t [path to your .jmx file] -l [path to your .jtl file]
    

    For example, if your .jmx file is called "Wikipedia_Performance_Load_Test.jmx" and you want to save the results to a file called "result.jtl", the command would be:

    jmeter -n -t Wikipedia_Performance_Load_Test.jmx -l result.jtl
    
  • You can add other elements, such as listeners, to monitor the performance of the test.

Result 1

Result 2

By using parameterization with a CSV file, you can easily test the performance of your application with different data sets. In this case, we were able to test the search functionality of Wikipedia with 100 users and different city names. This method can be applied to other scenarios as well, such as testing different login credentials or different input fields in a form.

loadtesting Article's
30 articles in total
Favicon
Everything you need to know about load testing concurrent users
Favicon
Scaling Node.js: Handling 1 Million Requests Like a Pro
Favicon
A Critical Performance Issue Led Me to Discover EchoAPI's Load Testing
Favicon
Comparing the K6 Operator vs Testkube for Load Testing
Favicon
Performance Testing with NeoLoad
Favicon
How I created a unique PPT for "Load Testing" KT!
Favicon
Capacity Planning as a Way to Minimize Unforeseen Business Expenses
Favicon
Load testing 3scale
Favicon
Getting Started with Load Testing using Locust
Favicon
JMeter-Dynamic Load Testing of Restful APIs
Favicon
K6 Development: Beyond The Basic Setup
Favicon
Load Testing Serverless Application using k6
Favicon
How to use CSV file for parameterization in JMeter
Favicon
Installing Apache JMeter using Homebrew
Favicon
Thread Group in Jmeter: Understanding its Components and Use Cases
Favicon
Running Load-Test-as-Code Simulations with Gatling
Favicon
Load-Test-as-Code for Non-Coders!
Favicon
How Software Performance Testing Can Help Your Business Succeed this Holiday Season
Favicon
Library for easy implementation of instant load testing
Favicon
My journey with AWS
Favicon
Loadtest Websocket Server
Favicon
How to get started with Load Testing?
Favicon
AWS Lambda vs. Cloudflare Workers vs. AWS Cloudfront Function cold start comparison with Ddosify Cloud
Favicon
Performance Testing via Artillery.io - user guide
Favicon
Load testing with Playwright
Favicon
Performance Testing Report. The importance of Load and Stress Testing your Systems.
Favicon
Load Test your NodeJS app using K6
Favicon
Load Testing withΒ Locust
Favicon
Vegeta load testing a quick tutorial with GET examples
Favicon
Load Testing Your API with Postman

Featured ones: