Introducing the Random CSV Data Set Config Plugin on JMeter
This Apache JMeter plugin gives you the ability to parameterize your Test Plan from a CSV file in random order of records for data-driven testing.
Join the DZone community and get the full member experience.
Join For FreeThe Random CSV Data Set plugin is a new Apache JMeter™ plugin that I developed (released November 2017), which solves data-driven testing needs. The Random CSV Data Set Config plugin provides the capability to parameterize your Test Plan from a CSV file in random order of records. Until now, JMeter users who used the default CSV Data Set Config element could only read records in sequential order. The Random CSV Data Set Config plugin solves this problem.
The Random CSV Data Set Config plugin is available to download from the JMeter Plugins Manager.
1. Open the JMeter Plugins Manager on JMeter (If you haven't it, read How to Install the JMeter Plugins Manager)
2. Select 'Available Plugins' tab on JMeter Plugins Manager
3. In the search field write 'Random', and then select the plugin's checkbox
4. Click the button 'Apply Changes and Restart JMeter'
First, create a test-plan that contains one Thread Group. A Thread group consists of an "HTTP Request" and a "Random CSV Data Set Config." Also, add a "View Results Tree."
Then select the "Random CSV Data Set Config" element in your Test Plan tree and set it up with the following settings:
A description of these parameters:
- Filename - The path to your file. Relative paths are resolved with respect to the path of an ctive test plan.
- Fileencoding - The encoding that will be used to read this file.
- Delimiter - The delimiter that will be used to split records in the file.
- Variablenames - This is the equivalent to a "column name" in a spreadsheet.
- Randomorder - The plugin will get records from the file in random order. This is the part that provides this element's added value. If you don't select this option, the element will work like the regular CSV Data Set Config.
- Rewindonend of list - After one loop of testing completes, JMeter runs another one. This is valuable for checking your performance over time. When this is checked with "Random order", the second and following loops will test the variables in a different order each time.
- First line is CSV header - If you specified "Variable names" and you want to skip the first line in the file check this checkbox.
- Independent list per thread - Each thread will go through their own copy of the reader. This imitates real-world scenarios. When this is checked with "Random order", each thread runs its own random sequence instead of all of them going over the same order of variables.
Click 'Test CSV Reading' to see if the plugin works with the settings provided. You don't have to run the complete test, as required until now in JMeter, thus saving time and resources.
In the preview area you can see how the plugin parsed this file. Please note that the preview area only shows 20 records from the CSV file.
Here you can see the content of the file in a simple text editor:
After you set up the "Random CSV Data Set Config" element, select the "HTTP Request" component in your Test Plan. For example, we'll send a Log In request with two parameters: 'login' and 'password'.
In the 'HTTP Request,' specify the HTTP Method, Path, and parameters that will be sent. As you can notice, the value field has the same name as the variable in the 'Random CSV Data Set' or header from your file. The construction ${....} means it is variable, but not an absolute value.
After these steps, save your Test Plan and run the test. In 'View Results Tree', we can see that the requests was sent with the values from our CSV file:
WARNING: The config reads the files at the beginning of the test. Therefore, there will be a delay and a large memory consumption for larger files.
That's it! You now know how to use the CSV Data Set Config Plugin, which was developed as part of BlazeMeter's investment in the JMeter open source community.
Now that you know how to use the Random CSV Data Set Config Plugin, you can learn more JMeter from our free JMeter Academy.
Published at DZone with permission of Artem Fedorov, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments