Jmeter 初识四 —— If Controller 使用方法总结

If Controller ,Jmeter官方介绍:https://jmeter.apache.org/usermanual/component_reference.html#If_Controller

The If Controller allows the user to control whether the test elements below it (its children) are run or not.

By default, the condition is evaluated only once on initial entry, but you have the option to have it evaluated for every runnable element contained in the controller.

The ‘If Controller’ has a few parameters:
  • Name - the controller that is used to identify an element in the JMeter elements tree
  • Comments - the field that you can use to include a descriptive explanation of a specified condition (sometimes a condition might be very complicated and it’s useful to leave such comments as a reference)
  • Expression (must evaluate to true or false) - a condition that is verified by the execution flow to decide if children elements should be executed or not. By default, the condition is interpreted as a Javascript code that returns “true” or “false”
  • Interpret Condition as Variable Expression? - this parameter is designed for cases when you don’t need to evaluate Javascript code. The default method takes and interprets a specified condition as Javascript code, and after that it verifies if the result equals true or false. But if you select this parameter, then no Javascript interpretation will be used and the condition will be treated like a JMeter variable (don’t worry, we will cover this thoroughly in one of the examples further on)
  • Evaluate for all children? - if this property is selected then the specified condition will be checked for each child entry and not only once, as it is done by default

If Controller will internally use javascript to evaluate the condition but this can have a performance penalty. A better option (default one) is to check Interpret Condition as Variable Expression?, then in the condition field you have 2 options:

If controller 内部将使用javascript来评估条件,这会造成性能的损失,我们建议勾选 Interpret Condition as Variable Expression? 

1.  If Controller using javascript 

    返回值是 true / false 的变量 。 

    

2.  If Controller using expression 

     使用jmeter自带的方法,比如 ${__jexl3()} 来判断里面的表达式,返回值必须是 true/false .

    

     

Examples:

猜你喜欢

转载自blog.csdn.net/gys666/article/details/80563553
今日推荐