Performance test - summary of commonly used important functions in Jmeter

1. ${__counter(,)} counter - function of adding 1

疑问:假如加2,使用计数器 -计数器超过最大值后重新开始计数
重点:最大值, 如果运行结果超过最大值时,又会从起始值开始循环每个
用户独立计数器:多线程时,每个用户都是从起始值开始计数,跟线程号有关(${__threadNum} 获取线程号函数)

The counter precautions are shown in the figure:

2. Several time-related functions

${__time(,)} 默认获取当前时间戳函数,但可以设置格式,比如yyyy-MM-dd 年月日的格式 HHmmss 时分秒 S毫秒
${__dateTimeConvert(,,,)} 时间格式转换,默认转换当前时间,参数为时间,原来的格式,目标格式
${__timeShift(,,,,)} 数据格式化,时间偏移---直接查看帮助文档,时间区间,可能要用到
${__RandomDate(,,,,)} 随机日期

3. Encryption function - ${__digest(,,,,)}

Encryption simple encryption

4. ${__intSum(,,)} integer addition function

现在我也找了很多测试的朋友,做了一个分享技术的交流群,共享了很多我们收集的技术文档和视频教程。
如果你不想再体验自学时找不到资源,没人解答问题,坚持几天便放弃的感受
可以加入我们一起交流。而且还有很多在自动化,性能,安全,测试开发等等方面有一定建树的技术大牛
分享他们的经验,还会分享很多直播讲座和技术沙龙
可以免费学习!划重点!开源的!!!
qq群号:110685036

 

5. Attribute-related functions

${__P(,)} 获取属性函数
${__property(,,)} 获取属性函数--P 只是property这个函数的简写
${__setProperty(,,)} 设置属性函数--设置jmeter的动态属性

属性:以.properties结尾的文件,都是jmeter的属性配置文件,是jmeter工具自身带有的标签。
jmeter工具属性:
   jmeter属性:可能被改变 
        静态属性:写在properties文件中属性信息,都是静态属性 
        动态属性:运行过程中,动态定义属性系统属性:os、jdk ===这个系统属性信息,是不可改变

问题1:属性vs参数\变量区别 
属性是jmeter工具具有,所有,jmeter中的线程组要使用属性,都可以使用 参数、变量,有局限访问

问题2:动态属性:一直存在?还是朝生夕死?
动态属性,是在运行过程中产生的,关闭jmeter,就是自动释放了。

问题3:线程组执行顺序-并行的?取样器是从上到下的
jmeter中,多个启用线程组,在执行时,默认是并行执行,性能测试中就是并行执行
在性能测试中,我们不会勾选 测试计划中 “独立运行每个线程组”
因为混合场景设计不会等一个线程组运行结束后再取运行其他线程组,就是说一个可能登录,一个人可能在注册,模拟的是多个人,所以不同场景

6. How to reference dynamic properties across thread groups

获取线程组1的变量保存为新的属性名-${__setProperty(,,)} 设置属性函数--设置jmeter的动态属性
属性显示里可以查看到保存的属性
线程组2引用步骤1保存的属性名 -${__P(,)} 获取属

Maybe the first one has not obtained the value, but because the performance test is a large number of parallel, the failure to obtain the value in the 1.2 does not affect the overall situation.

7. Splicing function-${__V(,)} splicing function

错误方法:
${var_${__counter(,)}} -----我们期望它得到过程是${var_1} ${var_2} ${var_3} 最终的结果是变量的值 实际是要进行两次变量计算

正确方法:
${__V(var_${__counter(,)},)} -----“前缀_可变后缀” 变量名值

应用场景:
类似:var_1 var_2 前缀相同,后缀是递增数字的变量名称,常见于 jdbc从数据库中获取数据时。
select name from table where id like '123%'; 
结果可能有多条数据这个脚本就会返回多个name值, 我用table_name这个变量来接收值,table_name_1,table_name_2

Finally, I would like to thank everyone who has read my article carefully. Looking at the increase in fans and attention, there is always some courtesy. Although it is not a very valuable thing, if you can use it, you can take it directly!

Software Testing Interview Document

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Alibaba, Tencent, Byte, etc., and some Byte bosses have given authoritative answers. After finishing this set I believe everyone can find a satisfactory job based on the interview information.
 

Insert image description here

Guess you like

Origin blog.csdn.net/jiangjunsss/article/details/132995518