The use of __CSVRead of Jmeter's common functions

http://blog.csdn.net/xinwang/article/details/9816293

If the __CSVRead function is used to parameterize the script, when different variables in the script require different parameter values, the __CSVRead function can be considered.

Take the user name and password for logging in as an example: In the actual stress test, it is necessary to simulate the use of different users to access the system concurrently. At this time, we need to parameterize the user name and password in the script; the following describes how to use the csvread function:

1. Prepare a list of parameter values. The file format is: csv or txt file, which saves the parameter values ​​to be read by the variables. Each variable is separated by a comma. Each row represents each set of parameter values, and each column represents the same variable;
if 10 different users are prepared, the file name is user parameter.txt, and the user name and password are as follows:
[email protected],12
test02@sina .com,12345678
[email protected],hai123
[email protected],12abc
[email protected],23dcs
[email protected],ed12q
[email protected],jumper
[email protected],poi2qwe
test09@sina. com,122dewq
[email protected],123dew23

2. After preparing the list of parameter values, open the function assistant of Jmeter, select the csvread function, and generate the function;
In Jmeter "Options"-->Select "Function Assistant Dialog"-->Select the csvread function or directly use the shortcut key Ctrl+F to open, where:
  CSV file to get values ​​from | *alias: indicates the file to be read The path should be an absolute path (such as: D:\Software\jmeter\User parameter.txt)
  CSV file column number | next| *alias: indicates which column of data the current variable reads, note that the first column is 0
and   click the generate button , a function is generated, such as: ${__CSVRead(D:\Software\jmeter\User parameter.txt,0)}, which means that the data is read from the first column in the D:\Software\jmeter\User parameter.txt file . And so on.

3. In the script recorded by Jmeter, find the user name and password that require parameters for logging in, and parameterize the value of the user name and password, where:
replace the value of the user name with ${__CSVRead(D:\ Software\jmeter\User parameter.txt,0)}
replace the value of the password with ${__CSVRead(D:\Software\jmeter\User parameter.txt,1)}
to save the current script and complete the parameterization. (Note: if you want to To modify the parameter value to be read, you can directly modify the number in the txt list instead of re-modifying it in the csvread function generation)

4. When Jmeter executes, if there are multiple threads, read the numbers in the first line in sequence, if If there are more thread groups than the number of lines in the file, read in a loop.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326894128&siteId=291194637