jmeter-顯示log的方法,和腳本通用的語法


beanshell  log日志設置、log日志輸出

步驟:

1.從選項-勾選Log Viewer,打開調試窗口

2.選擇顯示log的等級

3.在腳本中加入要打引的log 如: log.info(‘日志’)

beanshell 通用的語句

  • vars.get(String paramStr):獲得變量值
  • vars.put(String key,String value):,將數據存到jmeter變量中
  • System.out.println("Set my encode");  這個不知道是不是只有java有先記錄在這里
  • log:寫入信息到jmeber.log文件,使用方法:log.info(“This is log info!”);
  • ctx:該變量引用了當前線程的上下文,使用方法可參考:org.apache.jmeter.threads.JMeterContext
  • vars - (JMeterVariables):操作jmeter變量,這個變量實際引用了JMeter線程中的局部變量容器(本質上是Map),它是測試用例與BeanShell交互的橋梁,常用方法:

    a) vars.get(String key):從jmeter中獲得變量值

    b) vars.put(String key,String value):數據存到jmeter變量中

    更多方法可參考:org.apache.jmeter.threads.JMeterVariables

  • props - (JMeterProperties - class java.util.Properties):操作jmeter屬性,該變量引用了JMeter的配置信息,可以獲取Jmeter的屬性,它的使用方法與vars類似,但是只能put進去String類型的值,而不能是一個對象。對應於java.util.Properties。 

    a) props.get("START.HMS");  注:START.HMS為屬性名,在文件jmeter.properties中定義 

    b) props.put("PROP1","1234"); 

  • prev - (SampleResult):獲取前面的sample返回的信息,常用方法:

    a) getResponseDataAsString():獲取響應信息

    b) getResponseCode() :獲取響應code

    更多方法可參考:org.apache.jmeter.samplers.SampleResult

    • sampler - (Sampler):gives access to the current sampler 

來源:  https://www.cnblogs.com/puresoul/p/4915350.html

官網:

http://jmeter.apache.org/usermanual/component_reference.html#BeanShell_Sampler

http://jmeter.apache.org/usermanual/component_reference.html#BeanShell_PreProcessor

 

http://www.pianshen.com/article/566441113/


免責聲明!

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



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