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:

 

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值