当前位置:网站首页>How to write a JMeter script common to the test team
How to write a JMeter script common to the test team
2022-07-28 08:31:00 【Li ziti】
High quality resource sharing
| Learning route guidance ( Click unlock ) | Knowledge orientation | Crowd positioning |
|---|---|---|
| 🧡 Python Actual wechat ordering applet 🧡 | Progressive class | This course is python flask+ Perfect combination of wechat applet , From the deployment of Tencent to the launch of the project , Create a full stack ordering system . |
| Python Quantitative trading practice | beginner | Take you hand in hand to create an easy to expand 、 More secure 、 More efficient quantitative trading system |
Peacetime learning 、 In the course of work , Some written jmeter Script , I believe most of them have encountered this problem . That's it : If you change a computer to run , The file path is different , It will cause the operation to fail .
Not long ago , I've really met once ,A Students wrote a script for pressure testing , Need the help of other test students , As a result, some people did not debug the code in advance , Causes an error to be reported during operation .
The main reason is ,A The script written by students cannot be used in general , Written in your own native path , Other students' file paths are different , Result in an error .
I really can't watch it anymore , Change the script , The pressure test was successfully completed .
So is there a solution to this problem , Of course there are , And it's very simple .
Let's look at the details
Get file directory
User defined variables
Let's look at the first way , Use it directly beanshell function , Put variables into user-defined variables , As shown below ; After the script runs , You can view the script path obtained in the log .
The code is as follows :
${\_\_BeanShell(import org.apache.jmeter.services.FileServer;FileServer.getFileServer().getBaseDir();,)}
Add this line of code , Follow up directly with shellPath Field to replace the fixed file path Just ok 了
beanshell processor
Add... To the thread group beanshell Post Processors , The configuration is as follows :
The code is as follows :
import org.apache.jmeter.services.FileServer;
String path = FileServer.getFileServer().getBaseDir();
log.info(path);
HTTP Default request header
Usually in a script , More than one interface request . We have to have host、protocol, If these general parameters are written in every request , Change once , Then this change is too big .
For this question , We can use HTTP Default request header , take host、protocol Good configuration , You will not fill in the following request host、protocol.
If the parameters are changed , It only needs to be changed once , Greatly improved efficiency . The configuration is as follows :
Functional applications
For the cases mentioned at the beginning , The problem is a little , Let's answer them one by one
CSV A parameterized
Scripts are packaged and delivered in a folder , A parameterization file is referenced in the script . The path of the file is A The fixed path of students , But other students got the script , The storage path is not consistent , Then run directly , There is bound to be an error .
For this point , Let's transform it as follows , The script path uses variables shellPath Replace it , As shown below :
Attachment upload
There is also an attachment upload request in the script , The file path is also fixed , Empathy , Use the variables we define shellPath Replace it , As shown below :
Delete data
The script is running , Some field data will be saved , But in order not to affect the new round of testing , So before the test , Will delete historical data .
alike , The file path we want to delete is also replaced with a variable shellPath, As shown below :
These are just jmeter Simple functions in use , Simple though , But the effect is great .
If the script is not general , Even if it works normally on your computer , Change the equipment , You have to debug again , It's not the effect we want .
When writing scripts , You still need to write general scripts , Some small details , You can't ignore .
- Get file directory
- User defined variables
- beanshell processor
- [ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-rFX8pyap-1657687686881)(https://blog.csdn.net/hong-fithing)] Warm a pot of sake
- Link to this article :https://blog.csdn.net/hong-fithing/p/16002029.html
- About bloggers : Comments and private messages will be answered as soon as possible . perhaps Direct personal trust I .
- Copyright notice : All articles in this blog except special statement , All adopt BY-NC-SA license agreement . Reprint please indicate the source !
- Solidarity bloggers : If you think the article will help you , You can click the bottom right corner of the article **【[ recommend ](javascript:void(0)】** once .
边栏推荐
- Usage of constructors
- Puzzle (004.3) pattern puzzle
- Swm32 series tutorial 5-adc application
- XSS知识点和20字符短域名绕过
- Can‘t connect to server on ‘IP‘ (60)
- Draw.io image saving path settings
- Awk from introduction to earth (16) discussion on the types of awk variables -- about the two types of numbers and strings
- Use of namespaces
- [book club issue 13] Chapter 1 multimedia processing tools ffmpeg tools
- pyspark更改列顺序存入iceberg数据库
猜你喜欢

See how Google uses pre training weights in target detection tasks | CVPR 2022

c语言中函数的介绍(血书20000字!!!!)
![[300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (VIII)](/img/86/8e97b4456e2ba9a8535debb099fee0.png)
[300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (VIII)

Plantuml Usage Summary

单片机IO口控制12V电压通断,MOS和三极管电路

Parse tree structure JS
![[event registration] cloud native technology exchange meetup, see you in Guangzhou on August 6](/img/08/b892bd6c14d5ba3691f9b7def29c35.png)
[event registration] cloud native technology exchange meetup, see you in Guangzhou on August 6

Talk about row storage and column storage of database

MPLS -- multi protocol label switching technology

【17】 Establish data path (upper): instruction + operation =cpu
随机推荐
How do we run batch mode in MySQL?
Protobuf basic grammar summary
Meituan Er Mian: why does redis have sentinels?
Understanding of spark operator aggregatebykey
Creation of status bar (29)
Freezing and thawing of pytoch
UE4 engine customizes screenpass and MRT output
豪华版h5俄罗斯方块小游戏源码
A group of South University students rely on science and technology to go to sea, with an annual income of 1billion
Chairman tree review
记录一次mycat连接Communications link failure问题解决
(Reprinted) plantuml Quick Guide
Viewing vantage's self drive from the "three good" kitchen electricity standard and the value proposition of "serious life"
Exception handling in SQL Server
一键开关机电路
CarSim simulation quick start (XIII) - steering system
uniapp的swiper动态设置current值不生效解决办法
2021-07-02
In QT multithreading, in which thread does the slot function perform analysis
Is the salary of test / development programmers unbalanced? Busy life, all kinds of job hopping





