Functions are special values that can populate the fields of any element like sampler in a test tree. Following is how a function call will look like ${_functionName(var1,var2,var3)}

Where ‘_functionName’is the name of the function. Example of such a function would be ${_threadName}

Note: If a parameter of the function contains a comma, then ‘\’ should be used as ${_time(EEE\, dd MMM YYYY)}.

Functions and variables can be used in any field of any component of a test but there are some restrictions for its use in a test plan. The function threadNum() does not make sense and will not work in a test plan level and also split() ,regex() and functions of variable evaluation will also not work in a test plan.

 

Categories of Functions

 

There are two categories of functions which are

  • User Defined Static Values (Variables): These variables allow the user for them to be replaced with their static value during the execution of the test tree. Variables are referenced as ${VARIABLE}. The variables will not work if they are nested as ${var${N}} and _V(variable) function as -${_V(Var${N})} can be used instead for versions after 2.2.

There are some variables which are internally defined by JMeter such as COOKIE_cookiename (containing the cookie value), START variables and so on.

  • Built in Functions

Following list of functions are categorised into these different types

TypeNameUse of the function
InformationSamplerNameGet the name or label of the Sampler
InformationthreadNumGet the thread number
InformationmachineNameGet the name of the local machine
InformationmachineIPGet the IP address of the local machine
InformationtimeGet the current time in different formats
InformationlogGet to log a message (and return the value)
InformationIognGet to log a message (empty return value)
InputFileToStringTo read an entire file
InputStringFromFileTo read a line from a file
InputCSVReadTo read from CSV delimited fie
InputXPathTo read from a file using an XPath expression
CalculationcounterTo generate an incrementing number
CalculationRandomTo generate a random number
CalculationintSumTo add integer numbers
CalculationlongSumTo add long numbers
CalculationRandomStringTo generate a random string
CalculationUUIDTo generate a random type 4 UUID
ScriptingjavaScriptTo process a JavaScript (Mozilla Rhino)
ScriptingBeanShellTo run a Beanshell script
ScriptingJexl,jexl2To evaluate a Commons Jexl expression
PropertiesPTo read a property (shorthand method)
PropertiespropertyTo read a property
PropertiessetPropertyTo set a JMeter property
VariablesVTo evaluate a variable name
VariablesevalTo evaluate a variable expression
VariablesevalVarTo evaluate an expression stored in a variable
VariablessplitTo split a string into variables
StringCharTo generate Unicode char values from a list of numbers
StringregexFunctionTo parse previous response using a regular expression
StringunescapeTo process strings with Java escapes (\n &\t)
StringescapeHtmlTo encode strings using HTML encoding
StringunescapeHtmlTo decode HTML encoded strings
StringTestPlanNameTo return name of current test plan
StringescapeOroRegexpCharsTo quote meta chars used by ORO regular expression