jmeter common functions

jmeter common functions

__csvRead function

  • Role: The csvRead function reads parameters from the outside, and the csvRead function can read multiple parameters from a file.
  • Function helper content:
    1. CSV file to get values ​​from | *alias: The file path to read, it should be an absolute path
    2. CSV file column number | next| *alias: read from the first column, note that the first column is 0

      There is a problem: when I used the control CSV Data Set Config, I always set the read file format to utf-8, but when I used the function, utf-8 could not read Chinese characters, and then I read it in ANSI

_Random function

  • Function: This function is to randomly read data replacement parameters from a certain number field. It can be used in the test script where multiple data records need to be added and some fields need to be unique. The randomly generated parameter is a number
  • Function: It can be used to parameterize the parameters sent by the http request, so that the parameterized parameters go to different random numbers in each thread when Jmeter is running. It is very convenient to use this function if a certain parameter cannot be repeated every time a request is sent before it can be stored in the database.
  • Function introduction:
    1. ${__Random(1,100,Random)} refers to generating random numbers from 1 to 100, which can be called with Random

__RandomString function

  • This function can select any characters from a fixed string to form a new string, which can be used to create names in batches, or nested with csvRead.
  • Function introduction: ${__RandomString(3,abcde,myUser)}
    1. The first parameter 10 indicates the length of the string you want to generate, required
    2. The second parameter abcde, which means random combination from these characters, not required
    3. The third parameter myUser indicates that the generated string is stored in this variable, not required

__counter function

  • Function: This function is a counter used to count the number of times the function is used. It starts from 1. It will automatically increase by 1 every time this function is called. It has two parameters. The first parameter is a boolean and can only be Set to "TRUE" or "FALSE", if it is TRUE, then each user has its own counter, which can be used to count how many times each thread song is executed. If it is FALSE, then use the global counter to count how many times this test has been run. The second parameter is the "function name"
  • Function introduction:
    1. The first parameter: True, if the tester wants the counters for each virtual user to remain independent from other users' counters. False, global counter
    2. The second parameter: the reference name of the value created by the reuse counter function. Testers can refer to the value of the counter like this: ${test}. This allows testers to create a counter and reference its value in multiple places.

Frequently asked questions

* 初始数值不会改变:不管是__Random 函数还是__counter函数,在多个线程还是循环中都都是同一个数据:
    1. 将函数放入用户定义的变量中会出现次问题
    2. 直接将函数放入请求提中会出现次问题(在jmeter3.3中存在)
    3. 建议将函数集中在【用户参数】中,便于管理
* 使用_csvRead函数时,编码格式不正确可能会读取不出来数据

Guess you like

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