Java – variable path parameter for rest Service Testing in JMeter
•
Java
I'm testing a rest service with path parameters
/my-service/v1/Customer/order/{ordernumber}
I want to increase the number by 1.5 for each request How do you achieve this in JMeter? Until now, I have passed a fixed path parameter, so our test results have only one input parameter
/my-service/v1/Customer/order/5247710017785924
Solution
The benefit of starting is to set your initial order value to user defined variable
If the startup sequence is "5247710017785924", you need to create the "OrderNumber" variable and set its value to 5247710017785924
After each request, you can increase the variable value by adding the BeanShell postprocessor to the HTTP sampler using the following code:
long ordernumber = Long.parseLong(vars.get("ordernumber")); ordernumber++; vars.put("ordernumber",String.valueOf(ordernumber));
And set the OrderNumber in the HTTP sampler path to
/my-service/v1/Customer/order/${ordernumber}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码