当前位置:网站首页>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 .
边栏推荐
- 驱动开发中platform设备驱动架构详解
- PTA 天梯赛练习题集 L2-002 链表去重
- [FPGA tutorial case 14] design and implementation of FIR filter based on vivado core
- Rk3399 platform development series explanation (interruption) 13.10, workqueue work queue
- 如何在Touch Designer 2022版中设置解决Leap Motion不识别的问题?
- 你不知道的互联网公司招聘黑话大全
- Senior programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization, and recommends collecting
- Database notes 04
- win系统下安装redis以及windows扩展方法
- Change the original style of UI components
猜你喜欢
【GNN】图解GNN: A gentle introduction(含视频)
Financial risk control practice - decision tree rule mining template
一个简单的代数问题的求解
Why does the data center need a set of infrastructure visual management system
The solution of a simple algebraic problem
JVM命令之 jinfo:实时查看和修改JVM配置参数
外设驱动库开发笔记43:GPIO模拟SPI驱动
cf:C. Column Swapping【排序 + 模擬】
Chain storage of stack
How to improve website weight
随机推荐
原生小程序 之 input切換 text與password類型
Solve pod install error: FFI is an incompatible architecture
[InstallShield] Introduction
ML之shap:基于adult人口普查收入二分类预测数据集(预测年收入是否超过50k)利用shap决策图结合LightGBM模型实现异常值检测案例之详细攻略
What is make makefile cmake qmake and what is the difference?
[daily training -- Tencent selected 50] 292 Nim games
深度聚类:将深度表示学习和聚类联合优化
The solution of a simple algebraic problem
Interview skills of software testing
Peripheral driver library development notes 43: GPIO simulation SPI driver
QT console output in GUI applications- Console output in a Qt GUI app?
一名普通学生的大一总结【不知我等是愚是狂,唯知一路向前奔驰】
外设驱动库开发笔记43:GPIO模拟SPI驱动
Jinfo of JVM command: view and modify JVM configuration parameters in real time
高并发大流量秒杀方案思路
Reading notes of Clickhouse principle analysis and Application Practice (6)
Swagger3 configuration
如果不知道这4种缓存模式,敢说懂缓存吗?
Career experience feedback to novice programmers
Experience of Niuke SQL