当前位置:网站首页>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 .
边栏推荐
- 【FPGA教程案例13】基于vivado核的CIC滤波器设计与实现
- 为不同类型设备构建应用的三大更新 | 2022 I/O 重点回顾
- The boss always asks me about my progress. Don't you trust me? (what do you think)
- @pathvariable 和 @Requestparam的详细区别
- Jstack of JVM command: print thread snapshots in JVM
- Go语学习笔记 - gorm使用 - 原生sql、命名参数、Rows、ToSQL | Web框架Gin(九)
- Things about data storage 2
- Detailed explanation of platform device driver architecture in driver development
- On the difference between FPGA and ASIC
- MySQL performance_ Schema common performance diagnosis query
猜你喜欢

Introduction to the extension implementation of SAP Spartacus checkout process

SAP Spartacus checkout 流程的扩展(extend)实现介绍

Check Point:企业部署零信任网络(ZTNA)的核心要素

3428. 放苹果

laravel 使用腾讯云 COS5全教程

POI excel export, one of my template methods

ML之shap:基于adult人口普查收入二分类预测数据集(预测年收入是否超过50k)利用shap决策图结合LightGBM模型实现异常值检测案例之详细攻略

Industrial Finance 3.0: financial technology of "dredging blood vessels"

为不同类型设备构建应用的三大更新 | 2022 I/O 重点回顾

目标检测中的损失函数与正负样本分配:RetinaNet与Focal loss
随机推荐
云加速,帮助您有效解决攻击问题!
原生小程序 之 input切換 text與password類型
Why does the data center need a set of infrastructure visual management system
PTA ladder game exercise set l2-004 search tree judgment
Classic questions about data storage
Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)
软件测试知识储备:关于「登录安全」的基础知识,你了解多少?
如何在Touch Designer 2022版中设置解决Leap Motion不识别的问题?
Type de texte de commutation d'entrée et de mot de passe de l'applet natif
DC-7靶机
Apple CMS V10 template /mxone Pro adaptive film and television website template
C. colonne Swapping [tri + Simulation]
Senior programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization, and recommends collecting
深度聚类:将深度表示学习和聚类联合优化
404 not found service cannot be reached in SAP WebService test
Cloud acceleration helps you effectively solve attack problems!
What is make makefile cmake qmake and what is the difference?
Data storage 3
测试开发基础,教你做一个完整功能的Web平台之环境准备
Change the original style of UI components