-->

how to use jsr 223 preprocessor in jmeter? [closed

2019-05-17 17:06发布

问题:

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.



标签: jmeter jsr223