JMeter Performance Testing Tutorial 23 - Variables and Functions in JMeter

preview_player
Показать описание
#jmeter #jmetervariables #jmeterfunctions #jmetertutorials #jmeterperformance testing
What are variables & functions and how to use them?
Functions and Variables
JMeter functions are special values that can populate fields of any Sampler or other element in a test tree.

Where "__functionName" matches the name of a function.
Parentheses surround the parameters sent to the function, The actual parameters vary from function to function. Functions that require no parameters can leave off the parentheses.

If a function parameter contains a comma, then be sure to escape this with "\", otherwise, JMeter will treat it as a parameter delimiter.
If the comma is not escaped - you will get an error such as:

This is because the string "Math. max(2,5)" is treated as being two parameters to the __javascript function:
Math. max(2 and 5)
Other error messages are possible.
Variables are referenced as follows:

${VARIABLE}
If an undefined function or variable is referenced, JMeter does not report/log an error - the reference is returned unchanged. For example, if UNDEF is not defined as a variable, then the value of ${UNDEF} is ${UNDEF}. Variables, functions (and properties) are all case-sensitive. JMeter trims spaces from variable names before use, so for example ${__Random(1,63, LOTTERY )} will use the variable 'LOTTERY' rather than ' LOTTERY '.

What can functions do?
There are two kinds of functions: user-defined static values (or variables), and built-in functions.
User-defined static values allow the user to define variables to be replaced with their static value when a test tree is compiled and submitted to be run. This replacement happens once at the beginning of the test run. This could be used to replace the DOMAIN field of all HTTP requests, for example - making it a simple matter to change a test to target a different server with the same test.

This type of replacement is possible without functions but was less convenient and less intuitive. It required users to create default config elements that would fill in blank values of Samplers. Variables allow one to replace only part of any given value, not just fill in blank values.

With built-in functions users can compute new values at run-time based on previous response data, which thread the function is in, the time, and many other sources. These values are generated fresh for every request throughout the course of the test.

Where can functions and variables be used?
Functions and variables can be written into any field of any test component (apart from the TestPlan - see below). Some fields do not allow random strings because they are expecting numbers, and thus will not accept a function. However, most fields will allow functions.

Functions that are used on the Test Plan have some restrictions. JMeter thread variables will have not be fully set up when the functions are processed, so variable names passed as parameters will not be set up, and variable references will not work, so split() and regex() and the variable evaluation functions won't work. The threadNum() function won't work (and does not make sense at the test plan level). The following functions should work OK on the test plan:

intSum
longSum
machineName
BeanShell
groovy
javaScript
jexl2/jexl3
random
time
property functions
log functions

Subscribe our channel for latest videos
==================================

#selenium #tutorials #free #2022 #training
Watch more free Selenium Tutorials

#JMeter #performance #testing #tutorials #free #2022 #training
Step by step free JMeter performance tutorials

#postman #API #testing #tutorial #manual #automation #free #2022 #training
Step by step free postman API manual and Automation Testing tutorials

#java #programming #tutorials #free #2022 #training
Step by step free Java programming tutorials

#agile #Youtube #series #free #2022 #training
Learn about agile from free YouTube series

#learn #software #testing #innovative #animated #videos #free #2022
Learn software testing free from innovative animated videos
Рекомендации по теме
Комментарии
Автор

😊 Hello and thank you for watching! We'd love to hear your opinions in the comments section.

TestingFunda
Автор

This video really helped me navigate to the set of functions and to use them directly on the http request body payload.

mainakhbhattacharjee
join shbcf.ru