Thursday, March 17, 2016

Parameterization in Jmeter





Parameterization in Jmeter:

We parameterize the input to run the test with different set of data for each user. We will provide the data in a file and provide as input for a field.

For this we will create a .csv file in Excel and save it. For this example, we will parameterize four fields. They are from Port, to Port, passFirst0 and passLast0.

The details to corresponding fields are as follows:





We have our requests as shown below:


To add the data to the test we need to add the config element as below:
Right Click on Thread Group -> Add -> Config Element -> CSV Data Set Config



The CSV Data Set details were entered as follows:



Parameters for the CSV Data Set config is as below:


Now once the CSV Data Set is configured, we need to set the variables at appropriate position as shown:



The value is set as ${Variablename} for the required fields. For example here passFirst0 is set as ${FirstName} and passLast0 is set as ${LastName}.

Let us now verify the values are passed correctly to the required parameters from the csv file. To perform this we will add a Listener -> View Results tree as below:


In Thread group set the Number of users as 2 and run. We see that there are two sample results as we ran for two users. We check the first thread we see that from Port is Frankfurt and to Port is London which is same as first record of our .csv file.


Now, let us verify the second thread results, we see that from Port is London and to Port is New York. So for two different customers there are two different input provided.


In the same way we can check for the customer firstname and lastname also.

No comments:

Post a Comment