目录:导读
前言
1、添加beanshell前置处理器
由于请求接口时,会传加密参数。加密过程会在请求之前完成,所以需要使用前置处理器中beanshell preprocessor

2、在测试计划中添加jar包路径

3、编写beanshell脚本

1)定义一个beashell变量:phoneNum,在Beanshell中可以直接调用jmeter中的内置函数
bash
String phoneNum = "1878294${__Random(1000,9999,num)}";
2)定义一个beashell变量:phoneNum
bash
String optCode = "testfan";
3)定义一个beashell变量:timestamp
bash
String timestamp = "${__time(,curtime)}";
4)定义一个beashell变量:data,用于接收拼接后的数据
bash
String data = phoneNum + optCode + timestamp;
log.info(data);
5)使用import函数,导入加密模块(jd-gui工具可以查看jar包)
bash
import com.lee.util.Md5Util;
导包放在最顶部

6)通过类名和函数名,直接调用md5方法,对拼接后的数据进行加密
bash
String md5Data = Md5Util.getMd5Hex(data);
log.info(md5Data);
7)将beanshell变量转为成jmeter变量
bash
vars.put("sgin",md5Data)
注意:beanshell变量和jmeter变量不要混用。
脚本后面加;
4、执行脚本

|-------------------------------------|
| 下面是我整理的2023年最全的软件测试工程师学习知识架构体系图 |
一、Python编程入门到精通

二、接口自动化项目实战

三、Web自动化项目实战

四、App自动化项目实战

五、一线大厂简历

六、测试开发DevOps体系

七、常用自动化测试工具

八、JMeter性能测试

九、总结(尾部小惊喜)
奋斗是一种信仰,不是为了超越他人,而是为了超越昨天的自己。让激情点燃心灵的火焰,坚持不懈地追逐梦想,在坎坷中成长,绽放出绚丽的人生华章。
成功的背后,是努力和坚持的汗水。不停地追求目标,放弃安逸的生活,用拼搏与奋斗书写辉煌篇章。相信自己的能力,努力拼搏,你就能创造属于自己的辉煌未来。
人生就像一场航海,即使面对波涛汹涌的大海,也要勇往直前。只要把握方向,坚定信念,扬帆远航,你的航程就一定充满着不断超越自我的精彩。相信自己,放飞梦想。