当前位置:网站首页>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 .
边栏推荐
- Apple CMS V10 template /mxone Pro adaptive film and television website template
- 绕过open_basedir
- laravel 使用腾讯云 COS5全教程
- 可极大提升编程思想与能力的书有哪些?
- Go语学习笔记 - gorm使用 - gorm处理错误 | Web框架Gin(十)
- 360织语发布7.0新品 为党政军、央国企打造专属“统一数字工作空间”
- [InstallShield] Introduction
- @pathvariable 和 @Requestparam的详细区别
- MFC BMP sets the resolution of bitmap, DPI is 600 points, and gdiplus generates labels
- If you don't know these four caching modes, dare you say you understand caching?
猜你喜欢
![[InstallShield] Introduction](/img/df/4522d06510ff918d00659b8358368f.jpg)
[InstallShield] Introduction

关于STC单片机“假死”状态的判别

如何在Touch Designer 2022版中设置解决Leap Motion不识别的问题?

Mac version PHP installed Xdebug environment (M1 version)

SubGHz, LoRaWAN, NB-IoT, 物联网
Interview questions and salary and welfare of Shanghai byte

Web authentication API compatible version information

Jmeter自带函数不够用?不如自己动手开发一个

win系统下安装redis以及windows扩展方法

【SQL实战】一条SQL统计全国各地疫情分布情况
随机推荐
Introduction to the extension implementation of SAP Spartacus checkout process
【FPGA教程案例13】基于vivado核的CIC滤波器设计与实现
A freshman's summary of an ordinary student [I don't know whether we are stupid or crazy, but I know to run forward all the way]
Deep clustering: joint optimization of depth representation learning and clustering
PTA 天梯赛练习题集 L2-004 搜索树判断
[solved] record an error in easyexcel [when reading the XLS file, no error will be reported when reading the whole table, and an error will be reported when reading the specified sheet name]
Bypass open_ basedir
如何在Touch Designer 2022版中设置解决Leap Motion不识别的问题?
Loss function and positive and negative sample allocation in target detection: retinanet and focal loss
SAP ABAP BDC (batch data communication) -018
Add salt and pepper noise or Gaussian noise to the picture
【GNN】图解GNN: A gentle introduction(含视频)
Go语学习笔记 - gorm使用 - gorm处理错误 | Web框架Gin(十)
PowerPivot - DAX (function)
Flask1.1.4 Werkzeug1.0.1 源码分析:启动流程
EMMC print cqhci: timeout for tag 10 prompt analysis and solution
Why does the data center need a set of infrastructure visual management system
Understand the deserialization principle of fastjson for generics
目标检测中的损失函数与正负样本分配:RetinaNet与Focal loss
ML's shap: Based on the adult census income binary prediction data set (whether the predicted annual income exceeds 50K), use the shap decision diagram combined with the lightgbm model to realize the