当前位置:网站首页>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 .
边栏推荐
- Use ffmpeg to generate single image + single audio streaming video in batches
- CarSim simulation quick start (10) - Modeling of braking system
- Window 2 - > toolbar (28-1)
- Usage of constructors
- Redis of non relational database [jedis client +jedis connection cluster]
- Kubernetes技术与架构(七)
- CarSim simulation quick start (XI) - Driver Model (1)
- Deluxe H5 Tetris game source code
- 一键开关机电路
- Opentsdb time series database
猜你喜欢

Es6: template string

Talk about row storage and column storage of database

uniapp的swiper动态设置current值不生效解决办法

【MindSpore易点通机器人-01】你也许见过很多知识问答机器人,但这个有点不一样

Can the variable modified by final be modified

业务数字化飞速奔跑,管理数字化亟待出发

jquey的基础语法

Spiral matrix

半桥BUCK电路—记录篇

XSS knowledge points and 20 character short domain name bypass
随机推荐
opencv+paddle orc 识别图片提取表格信息
New generation cloud native message queue (II)
pyflink连接iceberg 实践
Fxksmdb.exe process description
Prescan quick start to master the track editing path of Lecture 16
解决EMC、EMI传导干扰的八大方法
leetcode/单词长度的最大乘积
Openstack dashboard configuring public network access
Meituan Er Mian: why does redis have sentinels?
Unity中队列(Queue)的简单使用
How do we run batch mode in MySQL?
XSS知识点和20字符短域名绕过
Use ffmpeg to generate single image + single audio streaming video in batches
No super high-rise buildings | new regulations: what information does it reveal that no new buildings above 500 meters should be built?
[chart component kit] Shanghai daoning provides developers with steema download, trial and tutorial
JS candy xiaoxiaole game source code
What if the computer desktop icon has a small yellow lock?
Prescan quick start to master the transportation elements in lesson 14, prescan
【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(八)
sparksql 与flinksql 建表 与 连表记录





