how to use variable in jmeter like counter

和自甴很熟 提交于 2019-12-12 05:36:49

问题


I'm using loop controller inside the jmeter script, and I'm not able to fetch previous variable value in pre-processor beanshell.

Example:

var temp = 1; log.info("before : "+temp.toString()); temp++; prev.put("t",temp.toString());

Thanks in advance


回答1:


To save values b/w iterations:

Following is one of the ways to store and retrieve the values b/w iterations:

log.info("temp prev value " + vars.get("temp")); // first iteration returns null
vars.put("temp","something"); // store or override the value, so it will be available in next iterations.

To know iteration number:

If your need is to know the iteration number, then use Counter:

In beanshell preprocessor, access using reference name (counter) as shown below:



来源:https://stackoverflow.com/questions/40423570/how-to-use-variable-in-jmeter-like-counter

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