Jmeter生成UUID作为唯一标识符过程图解
作者:zzz紫川 时间:2022-09-17 03:35:36
在测试过程中,我们有时候需要一个唯一不重复的值(比如order_id)。我之前一直用的时间戳+计数器/随机函数拼接,但是有时候效果不太好,今天知道了UUID这玩意,可以来操作下。jmeter也提供了UUID函数,这里我参考百度写法用beanshell。
1、添加一个测试计划--线程组--BeanShellSampler
import java.util.UUID;
UUID uuid1 = UUID.randomUUID(); //获取UID的值
//把uuid中的‘-'去掉,然后传给zichuan。vars.put是beanshell的赋值函数
vars.put("zichuan",(uuid1.toString()).toUpperCase().replaceAll("-",""));
//不去掉‘-'的写法
//vars.put("zichuan",(uuid1.toString()).toUpperCase());
代码注释已经写得很清楚了,如果有多个,可以加个uuid2,uuid3......还多,那就改一下代码吧,比如用循环。
2、随便加个请求,验证一下,能不能取到(用${}引用)
看上去是没问题的,就这样了。
来源:https://www.cnblogs.com/zichuan/p/10907506.html
标签:Jmeter,UUID,标识符
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C++日期类计算器的模拟实现举例详解
2023-05-22 08:27:16
SpringBoot使用MyBatis-Plus解决Invalid bound statement异常
2022-12-23 12:13:13
Spring Security认证机制源码层探究
2022-07-27 19:05:26
![](https://img.aspxhome.com/file/2023/1/68511_0s.png)
Android自定义EditText实现淘宝登录功能
2023-04-20 01:33:04
![](https://img.aspxhome.com/file/2023/6/139656_0s.png)
Spring的事件监听机制示例详解
2023-01-25 18:40:42
![](https://img.aspxhome.com/file/2023/7/129977_0s.jpg)
Java并发编程示例(八):处理线程的非受检异常
2022-03-23 14:15:57
mybatis查询语句揭秘之参数解析
2021-07-10 01:17:18
Java通过PropertyDescriptor反射调用set和get方法
2023-10-11 19:34:17
如何在Intellij中安装LeetCode刷题插件方便Java刷题
2023-10-16 21:38:08
![](https://img.aspxhome.com/file/2023/3/132023_0s.jpg)
详解Android的四大应用程序组件
2023-05-23 02:00:32
C#使用Gembox.SpreadSheet向Excel写入数据及图表的实例
2021-09-30 01:58:54
![](https://img.aspxhome.com/file/2023/8/81048_0s.jpg)
java Socket实现网页版在线聊天
2022-10-19 12:13:42
Mybatis下的SQL注入漏洞原理及防护方法解析
2022-06-30 18:38:29
![](https://img.aspxhome.com/file/2023/2/63082_0s.png)
C#如何Task执行任务,等待任务完成
2022-03-06 11:31:31
![](https://img.aspxhome.com/file/2023/2/119452_0s.jpg)
C# 实现QQ式截图功能实例代码
2022-04-04 03:48:12
![](https://img.aspxhome.com/file/2023/2/89782_0s.png)
java中struts2实现简单的文件上传与下载
2022-12-23 22:53:21
dialog dismiss时键盘不消失的问题浅析及解决办法
2021-09-18 10:06:30
![](https://img.aspxhome.com/file/2023/0/120060_0s.gif)
C#图片查看器实现方法
2021-06-17 16:50:03
![](https://img.aspxhome.com/file/2023/1/72491_0s.gif)
Android 快速实现防止网络重复请求&按钮重复点击的方法
2023-08-29 17:31:45
Android实现简单水波纹效果
2021-11-09 12:40:45
![](https://img.aspxhome.com/file/2023/4/101814_0s.gif)