How to Work with CSV Files in JMeter? | Loadium

How to Work with CSV Files in JMeter?

One of the most common challenges in every test project is the test data management. Data is typically spread across multiple databases in…

How to Work with CSV Files in JMeter?

One of the most common challenges in every test project is the test data management. Data is typically spread across multiple databases in today’s business world and it’s hard to manage its complexity. Working with clean data is crucial when it comes to performance testing however realistic and reliable data is hard to create.

Before you start performance testing, you should consider how to maintain the data. Performance tests are very challenging since you simulate thousands of users on your application. It requires you to consume so much data in a short period of time. It’s very hard to revert the data to its old state when you need it. So you need to come up with a good strategy to handle the data successfully.

One other thing to consider in a performance test project is the caching mechanism. When you run a test with the same data, there’s a good chance that the app will start to cache the response. So your request won’t reach the server. For this reason, we can conclude that you need a variety of data.

JMeter lets you deal with data by using CSV files. Here are some tips about CSV usages;

Tip #1 Try to use the data as dynamic as possible

Browsing a website, filtering data in a website are good examples. Your data is on a website or an application, you just need to use this data by using your CSS or JQuery Extractors as told in this article (https://loadium.com/using-css-selectors-in-jmeter-scripts/) and randomize your actions. If you have a pagination, determine how many pages you have and try to navigate the last ones. You will definitely bypass the caching mechanism.

Tip #2 Be very careful about your iteration and data structure

Assume you have a very strict flow as below and you add a CSV Data Set Config to it. JMeter will only run the first line of the CSV file even if you have thousands of iteration in your Thread Group.

Why? Because JMeter opens the file every time a new iteration starts. That’s why only the first line will be used in your test. So you need to loop through the file as below. Therefore, during the test runs, JMeter opens the file and iterates through the data. Request of consuming the data will execute different parameters.

Tip #3 CSV Configuration

Your CSV Config has 3 configurations in it.

Recycle on EOF: In case it’s set to true when JMeter reaches the end of the file, it will go to the beginning and iterate the CSV file.

Stop Thread on EOF: Thread will stop its execution when JMeter reaches the end of the file. In case you have 20 iterations in a loop and 10 lines of data, JMeter will stop the execution at 10th request. So it will override the iteration number.

Sharing Mode: According to the configuration, you decide whether or not to allow other Thread Groups to use the CSV file.

All these tips we explained will be handy for your test execution.

You can read the original article at https://loadium.com/blog/how-to-work-with-csv-files-in-jmeter/

Happy performance testing!

Latest articles

All Articles →

How To Upload File in Jmeter

How To Upload File in Jmeter

What Is Visual Testing

What Is Visual Testing

Craft Powerful Performance Tests with Ease Loadium Script Builder

Craft Powerful Performance Tests with Ease Loadium Script Builder