首先摘抄一段官方文档的话:
The following BeanShell variables are set up for use by the script:
- log - (Logger) - can be used to write to the log file
- ctx - (JMeterContext) - gives access to the context
-
vars - (JMeterVariables) - gives read/write access to variables:
vars.get(key);
vars.put(key,val);
vars.putObject("OBJ1",new Object()); - props - (JMeterProperties - class java.util.Properties) - e.g. props.get("START.HMS"); props.put("PROP1","1234");
- prev - (SampleResult) - gives access to the previous SampleResult
- data - (byte [])- gives access to the current sample data
For details of all the methods available on each of the above variables, please check the Javadoc
根据官方文档可以看到, jmeter的beanshell前置处理器有一些内置的变量
log 对应的对象是Logger
ctx 对应的对象是JMeterContext
vars对应的对象是 JMeterVariables
props对应的对象是class java.util.Properties
prev对应的对象是SampleResult,但是需要注意他是获取前一次请求的SampleResult
data对应的对象是是一个字节数组,
有了几个内置的参数,基本上可以可以对jmeter进行完整的控制, 另外每个对象具体有哪些属性和方法, 可以参考jmeter对应的接口文档
参考官方文档 http://jmeter.apache.org/usermanual/component_reference.html#BeanShell_PostProcessor