当前位置:网站首页>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 文件
失败!
边栏推荐
- golang mqtt/stomp/nats/amqp
- VSphere implements virtual machine migration
- Meta AI西雅图研究负责人Luke Zettlemoyer | 万亿参数后,大模型会持续增长吗?
- The detailed page returns to the list and retains the original position of the scroll bar
- Exciting, 2022 open atom global open source summit registration is hot
- servlet(1)
- Study diary: February 13, 2022
- Free chat robot API
- 关于#数据库#的问题:(5)查询库存表中每本书的条码、位置和借阅的读者编号
- A preliminary study of geojson
猜你喜欢

Exciting, 2022 open atom global open source summit registration is hot

看抖音直播Beyond演唱会有感

1791. Find the central node of the star diagram / 1790 Can two strings be equal by performing string exchange only once

cf:D. Insert a Progression【关于数组中的插入 + 绝对值的性质 + 贪心一头一尾最值】

JVM_ 15_ Concepts related to garbage collection

SSH login is stuck and disconnected
![[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction](/img/b4/3d46a33fa780e5fb32bbfe5ab26a7f.jpg)
[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction

激动人心,2022开放原子全球开源峰会报名火热开启

282. Stone consolidation (interval DP)

KDD 2022 | EEG AI helps diagnose epilepsy
随机推荐
MIT doctoral thesis | robust and reliable intelligent system using neural symbol learning
C language programming (Chapter 6 functions)
The population logic of the request to read product data on the sap Spartacus home page
[groovy] compile time metaprogramming (compile time method injection | method injection using buildfromspec, buildfromstring, buildfromcode)
Arduino六足机器人
synchronized 和 ReentrantLock
Kotlin core programming - algebraic data types and pattern matching (3)
在产业互联网时代,将会凭借大的产业范畴,实现足够多的发展
Zhuhai's waste gas treatment scheme was exposed
1791. Find the central node of the star diagram / 1790 Can two strings be equal by performing string exchange only once
cf:D. Insert a Progression【关于数组中的插入 + 绝对值的性质 + 贪心一头一尾最值】
Model analysis of establishment time and holding time
BiShe - College Student Association Management System Based on SSM
毕设-基于SSM高校学生社团管理系统
Dedecms plug-in free SEO plug-in summary
In the era of industrial Internet, we will achieve enough development by relying on large industrial categories
Why can't mathematics give machine consciousness
Promise
Lone brave man
JVM_ 15_ Concepts related to garbage collection