当前位置:网站首页>JMeter's own functions are not enough? Why don't you develop one yourself
JMeter's own functions are not enough? Why don't you develop one yourself
2022-07-07 06:12:00 【Code classmate software test】
stay Jmeter In the function assistant , There are many built-in functions , such as Random、UUID、time wait . Using these functions can help us generate some data quickly , Do some logical processing . It's very convenient to use .
But in the actual interface testing process , There are many needs ,Jmeter Built in functions may not meet our needs . At this time, we can write our own code , Expand Jmeter Built in functions for .
For example, now I want to Jmeter Add a simple summation function to , The code logic is very simple , The general code is as follows :
public int sum(int a, int b){
return a + b;
}
Next, let's see how to encapsulate the custom logic into Jmeter Built in functions for .
New project
stay idea New China Java engineering , And then put Jmeter At the heart of jar package ApacheJMeter_core.jar( stay jmeter Of lib/ext You can find ) Import into project
stay src New under the directory package, It should be noted that package Your name must contain ".functions", such as "com.mtx.jmeter.functions",JMeter Design so that some core classes can be in non UI Can be loaded when running in the mode of , These classes will be loaded first . These classes are loaded through naming rules . All implementation function The class of must contain ".functions", Otherwise, the customized function will not take effect .
Create a custom function class
Create a new class , Inherit Jmeter The abstract class of AbstractFunction. In function class , The following properties and methods need to be defined .
attribute
List of parameter names of custom functions ,List type
The name of the custom function ,String type
Save an array of user input data ,CompoundVariable[] type
Method
execute: Execute the logic of the function
setParameters: Get the parameters entered by the user
getReferenceKey: Return the name of the custom function
getArgumentDesc: Return the description of all parameter names of the custom function
The specific code is as follows :
Export code as jar package
stay idea Set up the archive of the project artifacts, And then through build, Export code as jar package , Then put Jmeter Of lib/ext Under the table of contents , Restart Jmeter.
You can see the function name and parameters just now in the function assistant .
Input parameters , Operation function , You can see the calculation results .
边栏推荐
- [cloud native] what is the microservice architecture?
- Go语学习笔记 - gorm使用 - gorm处理错误 | Web框架Gin(十)
- PTA 天梯赛练习题集 L2-002 链表去重
- Go language learning notes - Gorm use - Gorm processing errors | web framework gin (10)
- On the discrimination of "fake death" state of STC single chip microcomputer
- Introduction to the extension implementation of SAP Spartacus checkout process
- mac版php装xdebug环境(m1版)
- 解决pod install报错:ffi is an incompatible architecture
- 一个简单的代数问题的求解
- 目标检测中的BBox 回归损失函数-L2,smooth L1,IoU,GIoU,DIoU,CIoU,Focal-EIoU,Alpha-IoU,SIoU
猜你喜欢
【FPGA教程案例13】基于vivado核的CIC滤波器设计与实现
window下面如何安装swoole
Industrial Finance 3.0: financial technology of "dredging blood vessels"
@Detailed differences between pathvariable and @requestparam
PowerPivot - DAX (function)
目标检测中的损失函数与正负样本分配:RetinaNet与Focal loss
外设驱动库开发笔记43:GPIO模拟SPI驱动
Dc-7 target
@pathvariable 和 @Requestparam的详细区别
Find duplicate email addresses
随机推荐
Check point: the core element for enterprises to deploy zero trust network (ztna)
Go语学习笔记 - gorm使用 - gorm处理错误 | Web框架Gin(十)
Why does the data center need a set of infrastructure visual management system
Ten stages of becoming a Senior IC Design Engineer. What stage are you in now?
Apple CMS V10 template /mxone Pro adaptive film and television website template
PowerPivot - DAX (function)
[InstallShield] Introduction
Deep clustering: joint optimization of depth representation learning and clustering
The solution of a simple algebraic problem
话说SQLyog欺骗了我!
生活中的开销,怎么记账合适
Things about data storage 2
@pathvariable 和 @Requestparam的详细区别
How to improve website weight
【SQL实战】一条SQL统计全国各地疫情分布情况
外设驱动库开发笔记43:GPIO模拟SPI驱动
PTA ladder game exercise set l2-004 search tree judgment
980. 不同路径 III DFS
JVM命令之 jinfo:实时查看和修改JVM配置参数
jmeter 函数助手 — — 随机值、随机字符串、 固定值随机提取