Jmeter Common Functions - Introduction to Parameterization

JMeter also has parameterization like LR. This article will introduce how to realize the parameterization of JMeter.

Parameterization: There is a login operation in the recording script, and the user name and password need to be entered. If the system does not allow the same user name and password to log in at the same time, or you want to better simulate multiple users to log in to the system.

At this time, it is necessary to parameterize the user name and password, so that each virtual user uses a different user name and password to access.

1. Prepare scripts and test data

1. Record a script (you can use the badboy tool to record), open it in jmeter, and find the page with the user name and password. as followsinsert image description here

2. We need "parameterized" data. We write five user names and passwords in Notepad and save them as .dat files. The encoding problem is more strict when using CSV Data Set Config to parameterize. Notepad is saved as Modify the encoding UTF-8. Note that the user name and password are in one-to-one correspondence, separated by a comma (,) in the middle.
insert image description here 

I put this file in my ( C:\JmeterWorkSpace\t.dat ) path.

2. Parameterization

Here are two parameterization methods: Function Assistant, CSV Data Set Config.

1. With the help of function assistants

a. Click "Options" in the menu bar ----> Function Assistant dialog box, see the figure below: CSV file column numbers start from 0, the first column is 0, the second column is 1, the third column is 2, and so on. .insert image description here

b. Copy the generated parameterization function, open the login request page, and find the field we want to parameterize in the parameterization on the right, here parameterize the user name and password, the first column is the user name, and the column number is 0; The second column is the password, and the column number is 1; just modify the corresponding parameterized field column number in the function.
insert image description here

Ok, now our parameterization setting is complete. When scripting, it will call the t.dat file under our C:\JmeterWorkSpace disk. The first column is the user, and the second column is the password.

2. With the help of the configuration element (CSV Data Set Config) in jmeter

a. Select the thread group, right-click, Add-Configuration Component-CSV Data Set Config
insert image description here

illustrate:

Filename — parameter entry file

File Encoding — the encoding of the file, set to UTF-8

Vaiable Names — The parameter items represented by each column in the file; the parameter items are separated by commas; the names of the parameter items should be consistent with the parameter items in the HTTP Request.

Delimiter — if the file is separated by commas, fill in commas; if you use TAB, fill in \t; (if the text file is in CSV format, it is separated by English commas by default)

Recycle on EOF? — True=When reading the file to the end, re-read the file from the beginning

False=Stop reading the file when the end of the file is read

Stop thread on EOF? — When Recycle on EOF is False, when the file is read to the end, stop the process. When Recycle on EOF is True, this item is meaningless

Remarks: Here I will briefly talk about the relationship between Recycle on EOF and Stop thread on EOF results in plain language

Recycle on EOF : Whether to loop to read parameters at the end of the file, options: true and false

Stop thread on EOF: Whether to stop the thread at the end of the file, options: true and false

When Recycle on EOF selects true, Stop thread on EOF selects true and false to make no sense. In layman's terms, it controls the non-stop loop reading in the front, and it doesn't make any sense to stop or run later.

When Recycle on EOF selects flase, Stop thread on EOF selects true, 4 threads, 3 parameters, then only 3 requests will be made

When Recycle on EOF chooses flase, Stop thread on EOF chooses flase, 4 threads, and 3 parameters, then it will request 4 times, but the fourth time has no parameters to take, and the cycle is not allowed, so the fourth request is wrong 

Guess you like

Origin blog.csdn.net/nhb687096/article/details/131680778