Jmeter counter function value to be displayed in Benashell Post Processor or sampler

Deadly 提交于 2019-12-13 02:44:17

问题


And I would like to evaluate i.e.

 ${productId_1} 
 ${productId_2} 

It should be as simple as:

${__V(productId${counter})}

Same approach applies to __counter() function:

${__V(productId_${__counter(,)})}

How can I display the value in Beanshell processor/sample instead of the thread name


回答1:


This is how one can display or use the counter function value or counter in conjunction with variable I am using this inside the Beanshell sample under the for each controller

Product = vars.get("Product_" + ${__counter(,)});

//save counter value into variable

counter = ${__counter(,)}; log.info("Counter ="+counter);




回答2:


It would be something like:

  • For counter: vars.get("counter")
  • For productId_${counter}: vars.get("productId_" + vars.get("counter"))

vars is a shorthand for JMeterVariables class instance.

Demo:


Be aware that starting from JMeter 3.1 it is recommended to use JSR223 Test Elements and Groovy language for any form of scripting so consider migrating to Groovy on next available opportunity. See Apache Groovy - Why and How You Should Use It guide for more details if needed.



来源:https://stackoverflow.com/questions/49508382/jmeter-counter-function-value-to-be-displayed-in-benashell-post-processor-or-sam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!