我需要在java上的BeanShell中的setUpThreadGroup数组中创建,然后在另一个ThreadGroup中使用它,所以我们需要将其设置为属性,然后在主ThreadGroup中,在数组中存储一些值。 我有一些这个:
String [][] massive = new String[${number_of_user}][8];
props.put("array",massive);
在主线程组中,我使用:
props.put("array",${__V(${double_coma}${__time(,)}${double_coma})});
System.out.println(props.get("array"));
最佳答案
- 不要将 JMeter 函数和/或变量内联到脚本中,您应该使用
vars
简写 JMeterVariables改为类 - 不要使用 Beanshell,since JMeter 3.1 you should be using JSR223 Test Elements and Groovy language相反
建议的代码更改:
String [][] massive = new String[Integer.parseInt(vars.get("number_of_user"))][8];
props.put("array", vars.get("double_coma") + System.currentTimeMillis() + vars.get("double_coma"));
有关使用可用于 JSR223 测试元素的 vars
和其他 JMeter API 简写的更多信息:Top 8 JMeter Java Classes You Should Be Using with Groovy
另请注意,在您的主线程组中,您覆盖属性而不是向数组添加某些内容,目前尚不清楚您要实现的目标,但看起来非常可疑。如果您只想将一些值从一个线程组传递到另一个线程组,您可以考虑使用 Inter-Thread Communication Plugin反而。
关于java - Jmeter:创建数组,然后设置属性,然后在数组中输入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59838047/