问题
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:
- First of all you need to choose a scripting language. As per JMeter Best Practices it's better to use Groovy
- Add HTTP Request and put
google.com
into "Server Name or IP" Add JSR223 PreProcessor as a child of the HTTP Request and put the following line into "Script" area:
sampler.setDomain("example.com");
- Add View Results Tree listener and run the test
- Inspect "Request" and "Response Data" tabs and ensure that request did go to
example.com
instead ofgoogle.com
- Disable or delete JSR223 PreProcessor
- Run the test again.
- 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