Four ways to add variables in Jmeter

1. Add the parameters sent with the request in the sample. Add different types of parameters according to the data type set by the server



2. User-defined variables

1. Create: Add -> Configuration Components -> User-Defined Variables

2. Function: All Samplers in the current thread group can refer to variables, which is convenient for script update; when the parameters change, just update the parameters of the corresponding variables in [User-defined variables], and do not need to modify each http one by one parameters in

3. Variable definition: It can be a specific value or a function (the function can be automatically generated: Options -> Function Assistant dialog)


4. Variable reference: The format of the reference variable in Sample is ${variable name}


 

3. Function Helper Dialog Box - Commonly Used Jmeter Functions (First Level Menu Bar -> Options -> Function Helper Dialog Box)

1.__Random: Take a random value between the maximum and minimum values. There are three parameters: the maximum value, the minimum value, the variable name of the random value obtained

For example, generate a random function in [1,100]

Note: When setting the thread properties, the number of loops must be greater than 1 for the random function to take effect

 

For example, ${__Random(1,100,)}, when the number of threads = 10 and the number of loops = 1, the result of 10 random functions is 1; when the number of loops > 1, the value will be randomly selected.

2.__P: Set the default value of the property. There are two parameters: variable name, default value (default value is 1). For example: ${__P(hostname,XXX)}: Returns the value of the attribute hostname, or returns the value XXX if the attribute is not defined

3.__CSVRead: Read strings from a CSV file. There are two parameters: file name, column number (0 means the first column)

4. ${__UUID}: random value, and the result is unique; different from __Random (random value, the result may be the same)

 

4. Create CSV Data Set Config

1. Create: Add->Configuration Components->CSV Data Set Config

2. Function: You can get data from .csv, .dat and other files and parameterize these data. When the data changes, only the original file needs to be changed, no need to change the script


3. Parameter meaning

1) Filename: file path (if the same path as the script, just enter the file name; otherwise, enter the full path)

2) File encoding: The encoding is consistent with the file format. If there is Chinese, it is best to use UTF-8

3) Variable names: parameter names, separated by, between parameters

4) Delimiter: the delimiter in the input file (csv/dat, etc.); replace the tab key with \t

5) Allow quoted data: Set to True when the acquired data contains ""

6) Recycle on EOF: After setting to True, the cycle value is allowed

7) Stop Thread EOF: When Recycle on EOF is false and Stop Thread EOF is true, after reading the records in the csv file, it stops running, and the number of threads and execution times are invalid.

8) Sharing Mode: Sharing mode: All threads: All threads, all threads take values ​​cyclically, thread 1 takes the first line, thread 2 takes the next line; Current thread group: The current thread group, each thread group takes values ​​cyclically; thread: all threads within this test plan take the first line

 

4. Call the variables in the CSV Data Set Config


 

 Article source: https://www.cnblogs.com/jessicaxu/p/7512680.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326177502&siteId=291194637