1. Background
In actual work, when using Jmeter as a performance script or interface script, it may be necessary to perform different operations on different conditions. Based on this requirement, the if controller can be used in Jmeter to achieve
Second, the actual operation
Logic Controller Location:
Under the thread group, execute: Add ---->> Logic Controller---->> If Controller
The most important thing in the if logic controller control is the Expression (must evaluate true or false) input box, where the expression that needs to be judged needs to be written. It can be seen from the must evaluate true or false that in actual use, only true or false can be filled in. A value such as false, so we need to use other modules or functions to convert the expression that needs to be judged (such as ${var}== 5) into true or false, and the judgment can take effect, directly convert ${var}== 5 like this The expression written to Expression is invalid.
From the information prompted by the controller, you can use the __jexl3 or __groovy function to calculate the value of the expression, which focuses on the use of __jexl3 in the if controller.
Jexl full name: Jakarta Commons Jexl, is an expression language (Java Expression Language) interpreter.
JEXL Expression to evaluate: Just fill in the expression that needs to be judged here.
Expression support:
== Whether it is equal, such as ${__jexl3(${VAR}==1,)}, determine whether the ${VAR} variable is equal to 1
!= is not equal, such as ${__jexl3(${VAR}!=1,)}, to determine whether the ${VAR} variable is not equal to 1
! Not, such as ${__jexl3(!(${VAR}!=1),)} negates the result of ${VAR}!=1
&& or || and and or, as in ${__jexl3(${VAR}==1 && ${name} != "heima",)}
> or >== greater than or equal, such as ${__jexl3(${count}>=10,)}
3. Summary
The conditional expression cannot be directly filled in the Expression of the if logic controller. It is necessary to use a function to calculate the conditional expression as true/false. The functions that can be used are __jexl3 and __groovy functions