[英]JMeter | How to define variables such that their scope is in {thread, Thread-Group, Test-Plan} from within BeanShell
I am trying to write a test plan, where a custom report is generated based on the text on the samplers. 我正在尝试编写一个测试计划,其中根据采样器上的文本生成自定义报告。 I could not scope the variables correctly in these three levels. 我无法在这三个级别中正确调整变量的范围。
loc = vars.get("local_count");
if(loc == null){
vars.put("local_count", "1");//available only in local thread level
}else{
temp = Integer.parseInt(loc) + 1;
vars.put("local_count", temp.toString());
}
log.info("the local count is " + vars.get("local_count");
glo = props.get("global_count");
if(glo == null){
props.put("global_count", "1");//available in test plan level
}else{
temp1 = Integer.parseInt(glo) + 1;
props.put("global_count", temp1.toString());
}
log.info("the global count is " + props.get("global_count");
Now try creating multiple Thread-Group and add this BeanShell sampler in each of them. 现在尝试创建多个Thread-Group并在每个中添加这个BeanShell采样器。
How to make a variable available in all the threads of a Thread-Group only(not on other thread groups).Providing constant-unique names in different thread groups is not an option.? 如何使变量仅在Thread-Group的所有线程中可用(而不是在其他线程组上)。在不同的线程组中提供常量唯一名称不是一种选择。
Could somebody help me. 有人能帮助我吗? Thanks in advance. 提前致谢。
Add BeanShell Sampler and insert this code: 添加BeanShell Sampler并插入以下代码:
vars.put("test","abcd");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.