1. 程式人生 > >Jmeter 後置處理器 BeanShell_PostProcessor 適用思考

Jmeter 後置處理器 BeanShell_PostProcessor 適用思考

首先摘抄一段官方文件的話:

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

props對應的物件是class java.util.Properties

data對應的物件是是一個位元組陣列

有了幾個內建的引數,基本上可以可以對jmeter進行完整的控制, 另外每個物件具體有哪些屬性和方法, 可以參考jmeter對應的介面文件

參考官方文件  http://jmeter.apache.org/usermanual/component_reference.html#BeanShell_PostProcessor