how to use jsr 223 preprocessor in jmeter? [closed]

瘦欲@ 提交于 2019-12-10 08:42:49

问题


Someone please help me how to do scripting using jsr223 preprocessor in Jmeter with some examples.

Any best site to get tutorial for the same.

Thanks in advance

SIJO


回答1:


For instance:

  1. First of all you need to choose a scripting language. As per JMeter Best Practices it's better to use Groovy
  2. Add HTTP Request and put google.com into "Server Name or IP"
  3. Add JSR223 PreProcessor as a child of the HTTP Request and put the following line into "Script" area:

    sampler.setDomain("example.com");
    
  4. Add View Results Tree listener and run the test
  5. Inspect "Request" and "Response Data" tabs and ensure that request did go to example.com instead of google.com
  6. Disable or delete JSR223 PreProcessor
  7. Run the test again.
  8. Ensure that request went to google.com via View Results Tree listener.

So the purpose of PreProcessors is do something before request in order to make the system prepared for the request or change request somehow (for instance you have dynamic number of parameters or dynamic number of files to send with the request and don't want to hardcode it).

In above example sampler stands for HTTPSamplerProxy, see JavaDoc for available methods and fields. Also check out Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For! guide for details on groovy engine installation and scripting best practices.



来源:https://stackoverflow.com/questions/36444737/how-to-use-jsr-223-preprocessor-in-jmeter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!