JMeter的“如果控制器"有参数吗? [英] JMeter "if controller" with parameters?
问题描述
我正在阅读 JMeter文档,并遇到了此信息框关于如果控制器":
I was reading the JMeter documentation and came across this info box about "If Controllers":
当条件被解释为Javascript时,脚本将不使用任何变量.如果需要访问此类变量,请选择将条件解释为变量表达式?".并使用__javaScript()函数调用.然后,您可以在脚本中使用对象"vars","log","ctx"等.
No variables are made available to the script when the condition is interpreted as Javascript. If you need access to such variables, then select "Interpret Condition as Variable Expression?" and use a __javaScript() function call. You can then use the objects "vars", "log", "ctx" etc. in the script.
我不太明白这一点.这是否意味着如果我想访问用户定义的参数",那么我只能通过编写一些JavaScript来访问它?然后,此框后面的示例将引用"$ {COUNT}"
I don't quite follow this. Does this mean if I want access to a "User Defined Parameter" then I can access it only by writing some JavaScript? The example that follows this box then refers to "${COUNT}"
有人可以用一个或两个例子来说明If Controller的用法吗?
Could someone clarify the usage of the If Controller, maybe with an example or two?
推荐答案
您可以简单地使用
${my_variable}=='1'
有时JMeter文档可能会令人困惑:)
Sometimes JMeter documentation can be confusing :)
编辑2017年9月27日:
这里的答案有效,但是当线程数超过40时,会对性能造成严重影响.
The answer here works but has a very bad performance impact when number of threads exceeds 40.
有关正确和效果最佳的答案,请参见下文:
See below for correct and most performing answer:
请参阅:
这篇关于JMeter的“如果控制器"有参数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!