当前位置:网站首页>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 .
边栏推荐
- 693. 行程排序
- 老板总问我进展,是不信任我吗?(你觉得呢)
- Type de texte de commutation d'entrée et de mot de passe de l'applet natif
- MFC BMP sets the resolution of bitmap, DPI is 600 points, and gdiplus generates labels
- Apple CMS V10 template /mxone Pro adaptive film and television website template
- 404 not found service cannot be reached in SAP WebService test
- 生活中的开销,怎么记账合适
- Go语学习笔记 - gorm使用 - 原生sql、命名参数、Rows、ToSQL | Web框架Gin(九)
- Jstat of JVM command: View JVM statistics
- Jmeter自带函数不够用?不如自己动手开发一个
猜你喜欢

深度聚类:将深度表示学习和聚类联合优化

Question 102: sequence traversal of binary tree

Red hat install kernel header file

高并发大流量秒杀方案思路

laravel 使用腾讯云 COS5全教程

Go language learning notes - Gorm use - Gorm processing errors | web framework gin (10)

JVM命令之 jstat:查看JVM統計信息

Jstat pour la commande JVM: voir les statistiques JVM

你不知道的互联网公司招聘黑话大全

Introduction to yarn (one article is enough)
随机推荐
生活中的开销,怎么记账合适
jvm命令之 jcmd:多功能命令行
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
[daily training -- Tencent selected 50] 292 Nim games
Senior programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization, and recommends collecting
一名普通学生的大一总结【不知我等是愚是狂,唯知一路向前奔驰】
云加速,帮助您有效解决攻击问题!
Jstat pour la commande JVM: voir les statistiques JVM
go-microservice-simple(2) go-Probuffer
Subghz, lorawan, Nb IOT, Internet of things
The boss always asks me about my progress. Don't you trust me? (what do you think)
【GNN】图解GNN: A gentle introduction(含视频)
Convert numbers to string strings (to_string()) convert strings to int sharp tools stoi();
测试开发基础,教你做一个完整功能的Web平台之环境准备
360织语发布7.0新品 为党政军、央国企打造专属“统一数字工作空间”
What is make makefile cmake qmake and what is the difference?
Reading notes of Clickhouse principle analysis and Application Practice (6)
Rk3399 platform development series explanation (WiFi) 5.53, hostapd (WiFi AP mode) configuration file description
Understand the deserialization principle of fastjson for generics
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]