Martkos IT Ltd

View Original

JMeter Random CSV

Apache JMeter has an ever growing number of plugins but sometimes the simple ones are often those over looked. The Random CSV Data Set Config builds on top of the default CSV Data Set Config. As the name suggests it provides the facility to randomly read values from a CSV file.

Installation

Download plugins-manager.jar and put it into lib/ext directory, then restart JMeter.

The Random CSV Data Set Config plugin within JMeter can be installed using the plugin manager. Click on Options > Plugins Manager and then click on “Available Plugins”. Click in the search box and type “random”. Click on the checkbox at the side of the “Random CSV Data Set Config” and then click Apply Changes and Restart JMeter.

Usage

Once installed the Random CSV Data Set Config can be found under the Config Element menu named “bzm - Random CSV Data Set Config”.

Example File - Dummy.csv

abc

def

ghi

jkl

mno

pqr

stu

vwx

yx

Random CSV Data Set Config looks very similar to CSV Data Set Config with

Filename - path and filename of CSV

File encoding - encoding type to use set to UTF-8 by default

Delimiter - the delimiter used within the file by default comma

Variable name - the name of the variable where the value will be stored

Random Order - enable/disable random order by default on

Rewind on the end of the list - behaviour once end of list reached by default rewind

First Line is CSV header - confirm whether to use line 1 as CSV header by default off

Independent list per thread - configure if separate lists are used per thread by default off

Test CSV Reading - executes a selection of lines in random order and displays output.

Create a Test Plan

In a basic Test Plan containing a Dummy Sampler we can read a random value and return it in the View Results Tree.

The dummy sampler is on the whole left with its default values but we add the variable “result” which will contain the random data value.

The Randomly chosen value = ${result}

On execution the $result will will be populated and written out to in the View Results Tree. If you select the sample result and click on the response data table. You should then see text similar to

Dummy Sampler used to simulate requests and responses

without actual network activity. This helps debugging tests.

The Randomly chosen value = jkl

The Random CSV Data Set Config is a relatively basic add-on but one that can be very useful where you have a limited data set.

FURTHER READING

Random CSV Data Set Config documentation