当前位置:网站首页>JMeter BeanShell的基本用法 一下语法只能在beanshell中使用
JMeter BeanShell的基本用法 一下语法只能在beanshell中使用
2022-07-06 01:02:00 【阿门之恋】
一、背景
BeanShell是由java编写的,是一个轻量级的脚本语言,也相当于一个小巧免费的JAVA源码解释器,支持对象式的脚本语言特性,亦可嵌入到JAVA源代码中,能动态执行JAVA源代码并为其扩展了脚本语言的一些特性。
二、BeanShell自带语法
// 1.日志打印
log.info("这是我的第一个beanshell");
log.error("这是我的第一个beanshell");
// 2.线程内的变量 可通过
vars.put("name","张三");
String name = vars.get("name");
log.info("-----线程变量name:"+name);
log.info(vars.get("age")==null?"20":vars.get("age"));
// 3.添加获取全局变量
props.put("_name","李四");
String _name = props.get("_name");
log.info("-----全局变量_name:"+_name);
// 4. 获取前面的取样器
String preCode = prev.getResponseCode();
String preData = prev.getResponseDataAsString();
log.info("获取前一个取样器的状体码---》"+preCode);
log.info("获取前一个取样器的返回值---》"+preData);
三、引用java代码处理复杂逻辑
3.1 方式一 直接写java代码
public int add(int a,int b) {
int count = a+b;
return count;
}
log.info("-----------a+B="+add(1,2));
3.2 方式二 引入.java 文件
// 方式二 调用.java 文件
source("D:/MainTest.java");
MainTest test = new MainTest();
log.info("-----------C+D="+test.add(2,2));
3.3 方式三 引入.jar 文件
失败!
边栏推荐
猜你喜欢
How to extract MP3 audio from MP4 video files?
图解网络:TCP三次握手背后的原理,为啥两次握手不可以?
Mobilenet series (5): use pytorch to build mobilenetv3 and learn and train based on migration
Ubantu check cudnn and CUDA versions
KDD 2022 | 脑电AI助力癫痫疾病诊断
Cf:d. insert a progression [about the insert in the array + the nature of absolute value + greedy top-down]
The third season of ape table school is about to launch, opening a new vision for developers under the wave of going to sea
Finding the nearest common ancestor of binary search tree by recursion
esxi的安装和使用
BiShe - College Student Association Management System Based on SSM
随机推荐
cf:H. Maximal AND【位运算练习 + k次操作 + 最大And】
Spark SQL null value, Nan judgment and processing
cf:D. Insert a Progression【关于数组中的插入 + 绝对值的性质 + 贪心一头一尾最值】
Dede collection plug-in free collection release push plug-in
Installation and use of esxi
Five challenges of ads-npu chip architecture design
Convert binary search tree into cumulative tree (reverse middle order traversal)
MobileNet系列(5):使用pytorch搭建MobileNetV3并基于迁移学习训练
Dynamic programming -- linear DP
KDD 2022 | EEG AI helps diagnose epilepsy
关于#数据库#的问题:(5)查询库存表中每本书的条码、位置和借阅的读者编号
Leetcode Fibonacci sequence
Cloud guide DNS, knowledge popularization and classroom notes
Dedecms plug-in free SEO plug-in summary
Cf:d. insert a progression [about the insert in the array + the nature of absolute value + greedy top-down]
Cf:h. maximum and [bit operation practice + K operations + maximum and]
MCU realizes OTA online upgrade process through UART
程序员搞开源,读什么书最合适?
cf:C. The Third Problem【关于排列这件事】
ubantu 查看cudnn和cuda的版本