当前位置:网站首页>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 .
边栏推荐
- Introduction to the extension implementation of SAP Spartacus checkout process
- Ctfshow-- common posture
- 高并发大流量秒杀方案思路
- Data storage 3
- 搞懂fastjson 对泛型的反序列化原理
- SQL Server 2008 各种DateTime的取值范围
- 深度聚类:将深度表示学习和聚类联合优化
- Go语学习笔记 - gorm使用 - 原生sql、命名参数、Rows、ToSQL | Web框架Gin(九)
- PTA 天梯赛练习题集 L2-003 月饼 测试点2,测试点3分析
- 【FPGA教程案例13】基于vivado核的CIC滤波器设计与实现
猜你喜欢
Nvisual network visualization
Jcmd of JVM command: multifunctional command line
苹果cms V10模板/MXone Pro自适应影视电影网站模板
一个简单的代数问题的求解
Reading notes of Clickhouse principle analysis and Application Practice (6)
A very good JVM interview question article (74 questions and answers)
@pathvariable 和 @Requestparam的详细区别
你不知道的互联网公司招聘黑话大全
驱动开发中platform设备驱动架构详解
Rk3399 platform development series explanation (WiFi) 5.53, hostapd (WiFi AP mode) configuration file description
随机推荐
你不知道的互联网公司招聘黑话大全
DC-7靶机
Mac version PHP installed Xdebug environment (M1 version)
如果不知道这4种缓存模式,敢说懂缓存吗?
[FPGA tutorial case 14] design and implementation of FIR filter based on vivado core
JVM监控及诊断工具-命令行篇
苹果cms V10模板/MXone Pro自适应影视电影网站模板
PTA TIANTI game exercise set l2-003 moon cake test point 2, test point 3 Analysis
Career experience feedback to novice programmers
Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)
当我们谈论不可变基础设施时,我们在谈论什么
云加速,帮助您有效解决攻击问题!
[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]
Add salt and pepper noise or Gaussian noise to the picture
可极大提升编程思想与能力的书有哪些?
PTA 天梯赛练习题集 L2-002 链表去重
Jmeter自带函数不够用?不如自己动手开发一个
搞懂fastjson 对泛型的反序列化原理
MySQL performance_ Schema common performance diagnosis query
Change the original style of UI components