Custom JMeter FunctionsIn addition to standard JMeter functions we provide: chooseRandomsince 1.0.1This function choose single random value from the list of its arguments. The last argument is not taken into choice, it is interpreted as variable name to store the result. Parameters:
Example, choosing random color and assigning it to randomColor variable: ${__chooseRandom(red,green,blue,orange,violet,magenta,randomColor)} doubleSumsince 0.4.2This function used to compute the sum of two or more floating point values. Parameters:
Example, returning 8.3 and also saving it to variable sumVariable: ${__doubleSum(3.5, 4.7, sumVariable)} envsince 1.2.0This function used to get a value of environment variable. Returns value of environment variable if variable was defined, variable name instead (or default value) . Parameters:
Example, returning value of ENVVAR and also saving it to variable someVariable (or defaultValue if ENVVAR is not set): ${__env(ENV_VAR, someVariable, defaultValue)} isDefinedsince 0.4.2This function used to determine if variable was already defined. Returns 1 if variable was defined, 0 instead. Parameters:
Example, getting defined status for variable name 'testVar': ${__isDefined(testVar)} MD5since 0.4.2This function used to calculate MD5 hash of constant string or variable value. Parameters:
Example, calculating MD5 for 'test': ${__MD5(test)} base64Encodesince 1.2.0This function used to encode a constant string or variable value using Base64 algorithm. Parameters:
Example, encoding 'test string': ${__base64Encode(test string)} base64Decodesince 1.2.0This function used to decode a constant string or variable value from Base64 into string. Parameters:
Example, decoding that returns 'test string': ${__base64Decode(dGVzdCBzdHJpbmc=)} strLensince 0.4.2This function used to compute the length of constant string or variable value. Parameters:
Example, returning 11 and also saving it to variable lenVariable: ${__strLen(test string, lenVariable)} Example, returning length of variable varName: ${__strLen(${varName})} substringsince 0.4.2This function is wrapper for Java String.substring method. Parameters:
Example, getting 'str' from 'test string': ${__substring(test string, 5, 8)} strReplacesince 1.4.0This function is wrapper for Java String.replace method. Parameters:
Example, getting 'banana dog orange' from 'banana apple orange': ${__strReplace(banana apple orange,apple,dog)} strReplaceRegexsince 1.4.0This function is wrapper for Java String.replaceAll method. Parameters:
Example, getting banana-apple-orange from banana apple orange: ${__strReplaceRegex(banana apple orange,' ',-)} uppercase and lowercasesince 0.4.2This functions used to transform the case of constant string or variable value. Parameters:
Example, transforming 'test' into 'TEST' and also saving it to variable someVariable: ${__uppercase(test, someVariable)} iterationNumsince 1.2.1Function returns the number of current iteration in thread group. Function has no parameters. ifsince 1.3.0This function provides a == b ? a : b syntax. Parameters:
Example, gettig different values for jmeter variable: ${__if(${size}, 5, ok, invalid)} caseFormatsince 2.0This function provides changing string case format. Parameters:
Example, save in myString Variable value "my-string" ${caseFormat("my String", "LOWER_HYPHEN", myString); Case modes available: 1. LOWERCAMELCASE - Lower camel case, output as: lowerCamelCase 2. UPPERCAMELCASE - Upper camel case, output as: UpperCamelCase 3. SNAKECASE/LOWERUNDERSCORE Snake or lower underscore case, output as: snakelowerunderscore_case 4. KEBABCASE/LISPCASE/SPINALCASE/LOWERHYPHEN - Lisp or kebab or spinal or lower hyphen case, output as: lis-keba-spinal-lower-case 5. TRAIN_CASE - Train case, output as: TRAIN-CASE 6. UPPERUNDERSCORE - Upper underscore case, output as: UPPERUNDERSCORE_CASE |
On this page:
|