jmeter跨线程调用和线程内调用

跨线程调用参数:

1、主要使用函数props.put()、__p()

(1)props.put()的作用是将变量更改为jmeter内置属性

(2)__P()则是直接调用被置为jmeter内置属性的变量

2、例如:(此函数在A线程组的BeanShell Sample中编写)

 //使用jmeter随机函数生成12为数字和字母混合密码
  String password = "${__RandomString(6,123456789,)}${__RandomString(6,qwertyuiopasdfghjklzxcvbnm,)}";
 //使用props.put()将变量password置为jmeter内置属性
  props.put("pass",password);  

3、创建B、C线程组将BeanShell Sample中的名称修改为:

${__P(pass1,)}

4、线程中插入Debug Sample和察看结果树

5、打印后结果:

线程组内参数调用:

1、使用函数vars.put

//在BeanShell中编写脚本生成随机密码
String password = "${__RandomString(6,123456789,)}${__RandomString(6,qwertyuiopasdfghjklzxcvbnm,)}";
//将变量更改为线程组内可以使用
vars.put("pass",password);

2、插入多个BeanShell进行打印

3、察看运行结果:

原文地址:https://www.cnblogs.com/zhuangshi/p/10482936.html