We know you want to do more with your JMeter scripts.
We came across many uses cases wherein customers wished to do more with their JMeter scripts, like ability to manipulate variables, or to use logs to debug the conditions. It is almost possible to achieve many of the use cases through the commonly available JMeter elements and augment them with the rich source of plugins available. There may be instances wherein it would be required for the test authors to script in order to manipulate the data before or after it is passed to samplers.
This blog will highlight steps on how to retrieve a user id from a JSON response and then pass it to the next request to fetch the details of a user. The details would be displayed on the log. This is a very common use case wherein it would be required to retrieve data based on extracted input from a prior request. Also, logging is a useful mechanism to debug testing scripts which is a common use case of using JSR223 elements in the test script.
There are broadly three categories of JSR223 elements supported within JMeter which are:
There are broadly two ways to script within a JMeter test plan:
Inline scripting refers to writing the script within the JMeter test plan itself in the designated space for scripting within the element.
To edit your JMeter script by using the Apache JMeter GUI in the inline scripting mode:
Insert the values for the id that you would want to fetch.
In this scenario we are trying to fetch the first elements id from the response.
In Azure Load testing you cannot alter the log levels, hence you may use the WARN level log to output and print values to the log.
To be able to reference it you would need to add the below function that would retrieve path of your external Groovy or BeanShell script referenced within your JSR223 element.
${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir();)}${__BeanShell(File.separator)}
Referencing an external script file in your load test script by using the Azure portal:
If you run a load test within your CI/CD workflow, you can add the external script file in the configuration file section of the YAMl.
Go ahead and use JSR223 to enable greater flexibility with scenario construction with your JMeter scripts.
You can join our global developer community with feedback and insights here.
Happy LoadTesting!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.