当前位置:网站首页>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 文件
失败!
边栏推荐
- Idea远程提交spark任务到yarn集群
- Leetcode 44 Wildcard matching (2022.02.13)
- golang mqtt/stomp/nats/amqp
- The growth path of test / development programmers, the problem of thinking about the overall situation
- The inconsistency between the versions of dynamic library and static library will lead to bugs
- [pat (basic level) practice] - [simple mathematics] 1062 simplest fraction
- Lone brave man
- Live broadcast system code, custom soft keyboard style: three kinds of switching: letters, numbers and punctuation
- C language programming (Chapter 6 functions)
- The population logic of the request to read product data on the sap Spartacus home page
猜你喜欢
《强化学习周刊》第52期:Depth-CUPRL、DistSPECTRL & Double Deep Q-Network
Questions about database: (5) query the barcode, location and reader number of each book in the inventory table
Mlsys 2020 | fedprox: Federation optimization of heterogeneous networks
esxi的安装和使用
Leetcode study - day 35
Spark AQE
从 1.5 开始搭建一个微服务框架——调用链追踪 traceId
如何制作自己的机器人
如何制作自己的機器人
Cve-2017-11882 reappearance
随机推荐
[groovy] XML serialization (use markupbuilder to generate XML data | set XML tag content | set XML tag attributes)
cf:C. The Third Problem【关于排列这件事】
Distributed base theory
Construction plan of Zhuhai food physical and chemical testing laboratory
MySQL storage engine
logstash清除sincedb_path上传记录,重传日志数据
[groovy] compile time metaprogramming (compile time method interception | find the method to be intercepted in the myasttransformation visit method)
有谁知道 达梦数据库表的列的数据类型 精度怎么修改呀
激动人心,2022开放原子全球开源峰会报名火热开启
Spark AQE
Fibonacci number
Cf:d. insert a progression [about the insert in the array + the nature of absolute value + greedy top-down]
China Taiwan strategy - Chapter 8: digital marketing assisted by China Taiwan
Lone brave man
Synchronized and reentrantlock
View class diagram in idea
GNSS terminology
VSphere implements virtual machine migration
猿桌派第三季开播在即,打开出海浪潮下的开发者新视野
[day 30] given an integer n, find the sum of its factors