当前位置:网站首页>The basic usage of JMeter BeanShell. The following syntax can only be used in BeanShell
The basic usage of JMeter BeanShell. The following syntax can only be used in BeanShell
2022-07-06 01:04:00 【Amen's love】
One 、 background
BeanShell By java Compiling , Is a lightweight scripting language , It is also equivalent to a small free JAVA Source interpreter , Support for object-oriented scripting language features , It can also be embedded in JAVA In the source code , Can dynamically execute JAVA Source code and extends some features of scripting language .
Two 、BeanShell Bring your own grammar
// 1. Log printing
log.info(" This is my first beanshell");
log.error(" This is my first beanshell");
// 2. Variables within a thread It can be done by
vars.put("name"," Zhang San ");
String name = vars.get("name");
log.info("----- Thread variable name:"+name);
log.info(vars.get("age")==null?"20":vars.get("age"));
// 3. Add get global variables
props.put("_name"," Li Si ");
String _name = props.get("_name");
log.info("----- Global variables _name:"+_name);
// 4. Get the sampler in front
String preCode = prev.getResponseCode();
String preData = prev.getResponseDataAsString();
log.info(" Get the shape code of the previous sampler ---》"+preCode);
log.info(" Get the return value of the previous sampler ---》"+preData);
3、 ... and 、 quote java Code processing complex logic
3.1 Mode one direct writing java Code
public int add(int a,int b) {
int count = a+b;
return count;
}
log.info("-----------a+B="+add(1,2));
3.2 Mode two introduce .java file
// Mode two call .java file
source("D:/MainTest.java");
MainTest test = new MainTest();
log.info("-----------C+D="+test.add(2,2));
3.3 Mode three introduce .jar file
Failure !
边栏推荐
- MYSQL---查询成绩为前5名的学生
- Dedecms plug-in free SEO plug-in summary
- [groovy] compile time meta programming (compile time method interception | method interception in myasttransformation visit method)
- Browser reflow and redraw
- 【文件IO的简单实现】
- Differences between standard library functions and operators
- Live broadcast system code, custom soft keyboard style: three kinds of switching: letters, numbers and punctuation
- Daily practice - February 13, 2022
- cf:H. Maximal AND【位运算练习 + k次操作 + 最大And】
- Finding the nearest common ancestor of binary tree by recursion
猜你喜欢
《强化学习周刊》第52期:Depth-CUPRL、DistSPECTRL & Double Deep Q-Network
Some features of ECMAScript
MYSQL GROUP_ The concat function realizes the content merging of the same ID
从 1.5 开始搭建一个微服务框架——调用链追踪 traceId
Cf:h. maximum and [bit operation practice + K operations + maximum and]
Differences between standard library functions and operators
Beginner redis
[groovy] compile time meta programming (AST syntax tree conversion with annotations | define annotations and use groovyasttransformationclass to indicate ast conversion interface | ast conversion inte
Pbootcms plug-in automatically collects fake original free plug-ins
Dede collection plug-in free collection release push plug-in
随机推荐
Spark DF adds a column
Arduino hexapod robot
Cf:h. maximum and [bit operation practice + K operations + maximum and]
Curlpost PHP
Gartner发布2022-2023年八大网络安全趋势预测,零信任是起点,法规覆盖更广
2020.2.13
FFT 学习笔记(自认为详细)
Dede collection plug-in free collection release push plug-in
Finding the nearest common ancestor of binary search tree by recursion
Novice entry depth learning | 3-6: optimizer optimizers
Starting from 1.5, build a micro Service Framework - call chain tracking traceid
Lone brave man
KDD 2022 | 脑电AI助力癫痫疾病诊断
MySQL storage engine
朝招金安全吗 会不会亏损本金
[groovy] XML serialization (use markupbuilder to generate XML data | set XML tag content | set XML tag attributes)
vSphere实现虚拟机迁移
golang mqtt/stomp/nats/amqp
图解网络:TCP三次握手背后的原理,为啥两次握手不可以?
Free chat robot API