Jmeter 前置處理器 BeanShell_PreProcessor 適用思考



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

Before invoking the script, some variables are set up in the BeanShell interpreter:

  • 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 (if any)
  • sampler - (Sampler)- gives access to the current sampler

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

sampler對應的對象是Sampler, 需要注意的是Sampler取樣器是jmeter中各種各樣取樣器的父類, 如果這個請求時http請求, 那么                     sampler就是HttpSampler

有了幾個內置的參數,基本上可以可以對jmeter進行完整的控制, 另外每個對象具體有哪些屬性和方法, 可以參考jmeter對應的接口文檔



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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM