6

我正在尝试编写一个测试计划,其中根据采样器上的文本生成自定义报告。我无法在这三个级别中正确地确定变量的范围。

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");

现在尝试创建多个线程组并在每个线程组中添加这个 BeanShell 采样器。

如何使变量仅在线程组的所有线程中可用(不在其他线程组上)。在不同的线程组中提供常量唯一名称不是一种选择。?

有人可以帮助我。提前致谢。

4

1 回答 1

2

添加 BeanShell Sampler 并插入以下代码:

vars.put("test","abcd");

在此处输入图像描述

于 2013-10-07T11:17:34.907 回答