Correlation and Parameterization in JMeter

Correlation is the most important part of scripting. It includes fetching dynamic data from preceding requests/calls and posting it to the subsequent requests. Due to the authentication mechanism used, if we just playback this script, the test will fail even for a single user.

In parameterization, the input values for the test are fetched from data files. These data files can be excel, CSV files. As you know, JMeter supports parameterization as it is a performance and load testing tool.

Correlation in JMeter

To obtain the values from previous request response (i.e. Correlation in terms of Performance Testing) we use regular expression extractor in JMeter. Regular expression extractor is a Post Processor element which is applied on to a request which when processed i.e. its response will yield our desired value.

The Match No column will tell the sampler which value needs to obtained when multiple values are obtained as a part of the regular expression. Suppose, from our regular expression, we have obtained 10 values and we want to use only the 3rd value. So match no column will have value as 3.

Similarly, if we provide 0 in Match No field, it will choose one random value out of the available values.

If we want to retrieve all the values we should use -1 in the match no field. The values obtained can be used with the index like ${Pagelink_1}, ${Pagelink_2} and so on. Note: Page link is the reference name in the regular expression extractor and it can be any meaning full name.

Parameterization in JMeter via CSV Dataset Config :

CSV Data Set Config is used to read lines from a file and split them into variables

By default, the file is only opened once, and each thread will use a different line from the file. When the end of file (EOF) is reached, and the recycle option is true, reading starts again with the first line of the file.

If the recycle option is false, and stop Thread is false, then all the variables are set to <EOF> when the end of file is reached. This value can be changed by setting the JMeter property CSV dataset.eofstring.

If the Recycle option is false, and Stop Thread is true, then reaching EOF will cause the thread to be stopped.

Note: The CSV file should be placed inside a JMeter bin directory.

Now you just need to substitute the variable name like ${username} inside the request.

You may also like: How to Execute a Test Plan Using JMeter?

Leave a comment

Your email address will not be published. Required fields are marked *