Jmeter various functions


When no parameter may be directly written $ {__ functionName}


  • If the parameter contains a comma, then be sure to use  \ to escape, otherwise JMeter will use it as a parameter separator;
  • Actual use, typically by helper function to generate a dialog function strings, not prone to error.

JMeter function is divided into the following categories:

Function type function name of the function enabled version of the role of
access to information function

__TestPlanName Returns current test program name TestPlanName __} {$
__threadGroupName returns the name of the current thread group 4.1
__threadNum return thread ID of the currently executing 1.X
__samplerName 2.5 returns the name of the current request
input string __log 2.2 log output function of the output
__time returns the current time in multiple formats 2.2 

$ {__ log (Message)}: write the log file, the form "... thread Name: Message".

$ {__ log (Message, OUT)}: written to the console window.

$ {__ log ($ {VAR} ,,, VAR =)}: write the log file, the form "... thread Name VAR = value".

YMD = yyyyMMdd.
HMS = HHmmss.
YMDHMS = yyyyMMdd-HHmmss.
USER1 = JMeter properties time.USER1.
USER2 = JMeter properties time.USER2.
The user can change the default attributes by modifying the format JMeter, e.g., time.YMD = yyMMdd

$ {__ time ()} return '1548133155689'

$ {__ time (YMD,)} return '20190128'

$ {__ time (dd / MM / yyyy,)} return '22 / 01/2019 '

Data input function

__StringFromFile string read from a text file, for reading the character string from a text file, each line is read, read multiple files support. Each call to read a line 1.9

File name path of the file name (path relative to the JMeter startup directory) .
If the serial number, path name should be suitable for delivery to the DecimalFormat. It is a
variable name of the variable name for subsequent calls whether the function
start sequence number initial sequence number (if omitted, will be regarded as the end of the loop count SEQ ID) NO
terminal ID final sequence number (if omitted, sequence number may be increased without limit) no

Read a single file:
$ {_ StringFromFile (demo.txt ,,,)} read demo.txt

Read multiple files, the file name in SEQ ID NO:
$ {_ StringFromFile (PIN.DAT ,,, 2)} read twice PIN.DAT
$ {_ StringFromFile (PIN # DAT ,, 1,3 '.' )} read PIN2.DAT PIN3.DAT PIN1.DAT
$ {_ StringFromFile (pin000 '.' ,, 6,8 DAT)} read pin006.dat pin007.dat pin008.dat

When using a sequence number, path name is used as the  java.text.DecimalFormat format string. The current serial number passed in as the only parameter. If the starting sequence number is not specified, then the As the use of path names.

__FileToString the read file into a string, each call to read the entire file is 2.4
1.9 __CSVRead return thread ID of the currently executing
__XPath XML file using 2.0 XPath syntax match
data calculation function

__counter counter function 1.9
__intSum sum of a plurality of integers 1.8.1
__longSum long integer summation 2.3.2
__Random returns a random integer between specified maximum and minimum values 1.9
__RandomDate returns given between the start date and end date value random date 3.3
_RandomString generates a random string of specified length according to a given character 2.6
__UUID 2.9 Universally unique identifier function
attribute information of function

determining whether there is a property __isPropDefined 4.0
__property summing a plurality of integers 1.8.1
__P simplified property function, for use with a property defined on the command line 2.0
__setProperty simplified property function, defined on the command line for the properties with 2.0 use
string manipulation functions __split the delimiter string split into a plurality of variables 2.0.2
__changeCase change case 4.0
prior to use regular expressions __regexFunction resolve the response 1.X
script function

__BeanShell beanshell script execution 1.X
__javaScript execute js script 1.9

$ {__ property (user.dir)} user.dir return value.
$ {__ property (user.dir, UDIR )} user.dir return value, and stored in the variable UDIR.

$ {__ property (abcd, ABCD , atod)} Returns the value of the property of abcd, if the property is undefined return atoD, and stored in the variable in ABCD.
$ {__ property (abcd ,, atod )} abcd returns the attribute value if the attribute is not defined atoD returns, the result value is not saved.
Definition string: VAR = "a || c | " split call function: $ {__ split ($ { VAR}, VAR, |)} Back "a || c |", and generates the following variables: VAR_n = 4 VAR_1 = a VAR_2 =? VAR_3 = c VAR_4 =? VAR_5 = null

$ {__ changeCase (greedy all the deficiencies \, knowing few \ judicious no upper)}
返回greedy ALL lacking for want of a few, true nothing

LOWER-- converted to lowercase:
return labor omnia vincit improbus

$ {__ changeCase (all the way to Rome to reach CAPITALIZE,)}
返回have reached all the way to Rome

Guess you like