Social Icons

Pages

Tuesday 7 October 2014

Function in Apache JMeter

JMeter functions are no different from normal languages like C, C++, Perl etc. These functions take some parameters and return some value after processing those arguments. By convention, JMeter function names always starts with '__' i.e. two underscores. 

A typical function call looks like: 


${__FunctionName(var1,var2)}

where:
FunctionName maches any function name like __XPath

NOTE: If a function parameter contains a comma, then be sure to escape this with "\", otherwise JMeter will treat it as a parameter delimiter. For example:
${__time(EEE\, d MMM yyyy)}. 
If the comma is not escaped, you will get an error such as:
ERROR - jmeter.functions.JavaScript: Error processing Javascript: [Math.max(2]
    org.mozilla.javascript.EvaluatorException: missing ) after argument list (#1)

LIST of functions:

Type of functionNameUsage
InformationthreadNumget thread number
InformationsamplerNameget the sampler name (label)
InformationmachineIPget the local machine IP address
InformationmachineNameget the local machine name
Informationtimereturn current time in various formats
Informationloglog (or display) a message (and return the value)
Informationlognlog (or display) a message (empty return value)
InputStringFromFileread a line from a file
InputFileToStringread an entire file
InputCSVReadread from CSV delimited file
InputXPathUse an XPath expression to read from a file
Calculationcountergenerate an incrementing number
CalculationintSumadd int numbers
CalculationlongSumadd long numbers
CalculationRandomgenerate a random number
CalculationRandomStringgenerate a random string
CalculationUUIDgenerate a random type 4 UUID
ScriptingBeanShellrun a BeanShell script
ScriptingjavaScriptprocess JavaScript (Mozilla Rhino)
Scriptingjexl, jexl2evaluate a Commons Jexl expression
Propertiespropertyread a property
PropertiesPread a property (shorthand method)
PropertiessetPropertyset a JMeter property
VariablessplitSplit a string into variables
VariablesVevaluate a variable name
Variablesevalevaluate a variable expression
VariablesevalVarevaluate an expression stored in a variable
StringregexFunctionparse previous response using a regular expression
StringescapeOroRegexpCharsquote meta chars used by ORO regular expression
Stringchargenerate Unicode char values from a list of numbers
StringunescapeProcess strings containing Java escapes (e.g. \n & \t)
StringunescapeHtmlDecode HTML-encoded strings
StringescapeHtmlEncode strings using HTML encoding
StringTestPlanNameReturn name of current test plan



Source: http://jmeter.apache.org


No comments:

Post a Comment

Please Comment for Any question or suggestions