MeterSphere(6):Beanshell前置脚本全局变量

MeterSphere(6):Beanshell前置脚本全局变量(Jmeter也适用)

//base64依赖
import org.apache.commons.codec.binary.Base64;

//随机数
String randomNumber1 = ${__Random(10000000,90000000)}+"";
String randomNumber2 = ${__Random(10000000,90000000)}+"";

//登录用管理员账号密码
vars.put("login_name_base64", Base64.encodeBase64String("admin".getBytes("utf-8")));
vars.put("login_pwd_base64", Base64.encodeBase64String("2020".getBytes("utf-8")));

//新增角色名称
String rolename = "rolename"+randomNumber1;
vars.put("rolename", rolename);

//修改角色名称
vars.put("rolename_new", "rolename"+randomNumber2);


//新增用户信息
String userName = "userName"+randomNumber1;
String userPwd = "Pwd"+randomNumber1;
vars.put("user_name", userName);
vars.put("user_pwd", userPwd);
vars.put("user_name_base64", Base64.encodeBase64String(userName.getBytes("utf-8")));
vars.put("user_pwd_base64", Base64.encodeBase64String(userPwd.getBytes("utf-8")));

vars.put("true_name", "trueName"+randomNumber1);
vars.put("role_id", "admin");
vars.put("mobile", "135"+randomNumber1);
vars.put("email", "test@123."+randomNumber1);

//用户ID (初始为空,创建成功后赋值)
vars.put("user_id", "");

//修改用户信息
vars.put("true_name_new", "trueName"+randomNumber2);
vars.put("mobile_new", "135"+randomNumber2);
vars.put("email_new", "test@123."+randomNumber2);

//修改用户密码
String userPwdNew = "Pwd"+randomNumber2;
vars.put("user_pwd_new", userPwdNew);
vars.put("user_pwd_new_base64", Base64.encodeBase64String(userPwdNew.getBytes("utf-8")));

你可能感兴趣的:(#,#,Jmeter,java,开发语言,后端)