Advantages of JSR223 Components & Groovy in JMeter

Our Articles

Advantages of JSR223 Components & Groovy in JMeter
May 5th, 2020 7:04 pm    Anand Govindasamy - JMX Enhancer

JSR223 assertion, pre-processor, post-processor and sampler are powerful components in JMeter. Their ability to cache compiled scripts has made them preferable to Beanshell components which consumes considerable amount of resources for their execution. We are creating load tests in JMeter to mesure the performance of our application. We cannot afford our JMeter scripts to have performance issues.

Simple JSR223 Assertion:

Let us consider a simple scenario where we need to abort the current iteration and proceed to the next iteration based on a condition. The below code fails the assertion, throws some information to the log and moves to the next iteration, if we encounter a 5XX response code from the server.


prev.getResponseDataAsString() can get the response data string, in case you want to validate a specific text in the server's response. JSR223 pre-processor and port-processor are used to perform operations before and after a sampler respectively. We have seen that the JMeter scripts of siebel applications demand a lot of pre-processors & post-processors.

Groovy Function in If Controller:

Apache recommends using __jexl3 or __groovy functions for JMeter to perform better. The below is a simple groovy function that will get the the current iteration number and will execute the If controller's child elements on every 2nd iteration. Please make sure that interpret condition as variable expression is checked.

Previous Article Blog Home Next Article