当前位置:网站首页>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 文件
失败!
边栏推荐
- 孤勇者
- BiShe - College Student Association Management System Based on SSM
- vSphere实现虚拟机迁移
- 程序员成长第九篇:真实项目中的注意事项
- 关于#数据库#的问题:(5)查询库存表中每本书的条码、位置和借阅的读者编号
- 小程序容器可以发挥的价值
- Four commonly used techniques for anti aliasing
- Finding the nearest common ancestor of binary search tree by recursion
- Zhuhai's waste gas treatment scheme was exposed
- Beginner redis
猜你喜欢

BiShe - College Student Association Management System Based on SSM
![[groovy] compile time meta programming (compile time method interception | method interception in myasttransformation visit method)](/img/e4/a41fe26efe389351780b322917d721.jpg)
[groovy] compile time meta programming (compile time method interception | method interception in myasttransformation visit method)
![[groovy] XML serialization (use markupbuilder to generate XML data | set XML tag content | set XML tag attributes)](/img/09/9076de099147b2d0696fe979a68ada.jpg)
[groovy] XML serialization (use markupbuilder to generate XML data | set XML tag content | set XML tag attributes)

Starting from 1.5, build a micro Service Framework - call chain tracking traceid
![[groovy] XML serialization (use markupbuilder to generate XML data | create sub tags under tag closures | use markupbuilderhelper to add XML comments)](/img/d4/4a33e7f077db4d135c8f38d4af57fa.jpg)
[groovy] XML serialization (use markupbuilder to generate XML data | create sub tags under tag closures | use markupbuilderhelper to add XML comments)

The inconsistency between the versions of dynamic library and static library will lead to bugs

Idea远程提交spark任务到yarn集群

For a deadline, the IT fellow graduated from Tsinghua suddenly died on the toilet

Recoverable fuse characteristic test

Building core knowledge points
随机推荐
Natural language processing (NLP) - third party Library (Toolkit):allenlp [library for building various NLP models; based on pytorch]
[groovy] compile time meta programming (AST syntax tree conversion with annotations | define annotations and use groovyasttransformationclass to indicate ast conversion interface | ast conversion inte
What is the most suitable book for programmers to engage in open source?
KDD 2022 | EEG AI helps diagnose epilepsy
How to extract MP3 audio from MP4 video files?
Questions about database: (5) query the barcode, location and reader number of each book in the inventory table
朝招金安全吗 会不会亏损本金
A preliminary study of geojson
JVM_ 15_ Concepts related to garbage collection
Interview must brush algorithm top101 backtracking article top34
猿桌派第三季开播在即,打开出海浪潮下的开发者新视野
RAID disk redundancy queue
云导DNS和知识科普以及课堂笔记
1791. Find the central node of the star diagram / 1790 Can two strings be equal by performing string exchange only once
The inconsistency between the versions of dynamic library and static library will lead to bugs
MIT doctoral thesis | robust and reliable intelligent system using neural symbol learning
详细页返回列表保留原来滚动条所在位置
NLP text processing: lemma [English] [put the deformation of various types of words into one form] [wet- > go; are- > be]
Exciting, 2022 open atom global open source summit registration is hot
[groovy] XML serialization (use markupbuilder to generate XML data | set XML tag content | set XML tag attributes)