当前位置:网站首页>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 .
边栏推荐
- 话说SQLyog欺骗了我!
- 3428. 放苹果
- Vscode for code completion
- EMMC print cqhci: timeout for tag 10 prompt analysis and solution
- JVM命令之 jstack:打印JVM中线程快照
- Check point: the core element for enterprises to deploy zero trust network (ztna)
- JVM command - jmap: export memory image file & memory usage
- Talking about reading excel with POI
- Classic questions about data storage
- 绕过open_basedir
猜你喜欢
目标检测中的BBox 回归损失函数-L2,smooth L1,IoU,GIoU,DIoU,CIoU,Focal-EIoU,Alpha-IoU,SIoU
Jstat pour la commande JVM: voir les statistiques JVM
DC-7靶机
JVM监控及诊断工具-命令行篇
Introduction to yarn (one article is enough)
Jinfo of JVM command: view and modify JVM configuration parameters in real time
【GNN】图解GNN: A gentle introduction(含视频)
高并发大流量秒杀方案思路
C. colonne Swapping [tri + Simulation]
Rk3399 platform development series explanation (WiFi) 5.52. Introduction to WiFi framework composition
随机推荐
【SQL实战】一条SQL统计全国各地疫情分布情况
Jinfo of JVM command: view and modify JVM configuration parameters in real time
Flask 1.1.4 werkzeug1.0.1 analyse du code source: processus de démarrage
@pathvariable 和 @Requestparam的详细区别
Apple CMS V10 template /mxone Pro adaptive film and television website template
[daily training -- Tencent selected 50] 235 Nearest common ancestor of binary search tree
On the difference between FPGA and ASIC
linear regression
Data storage 3
EMMC print cqhci: timeout for tag 10 prompt analysis and solution
Detailed explanation of platform device driver architecture in driver development
jvm命令之 jcmd:多功能命令行
C. colonne Swapping [tri + Simulation]
k8s运行oracle
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
How to improve website weight
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]
Industrial Finance 3.0: financial technology of "dredging blood vessels"
[SQL practice] a SQL statistics of epidemic distribution across the country
The boss always asks me about my progress. Don't you trust me? (what do you think)