JMeter – BeanShell Listener

In JMeter, BeanShell Listener is a scripting-based listener. It means that you will need to implement the listener logic by yourself using one of the supported scripting languages. Usually, it is helpful when you need to define logic based on your requirement and want to write some unique algorithm which is not currently provided by JMeter. You can create your own implementation of the algorithm using BeanShell listener.

JMeter - BeanShell Listener
Figure 01: JMeter – BeanShell Listener

How to add ‘BeanShell Listener’?

Follow the below steps:

  1. Select the appropriate element where you want to add the listener.
    1. Test Plan
    2. Thread Group
    3. Controller
    4. Sampler
  2. Right-click on the element
  3. Hover the cursor on ‘Add’
  4. Hover the cursor on ‘Listener
  5. Click ‘BeanShell Listener’

What are the input fields of ‘BeanShell Listener’?

‘BeanShell Listener’ has the following input fields:

  • Name: To provide the name of the timer
  • Comments: To provide arbitrary comments (if any)
  • Reset bsh.Interpreter before each call: Interpreter will be recreated by selecting the value of this option as ‘Yes’. 
  • Parameters: Parameters to pass to the BeanShell script. This is an optional attribute.  
  • Script file: A file containing the BeanShell script to run. The return value is used as a listener output generated by BeanShell script.
  • Script: The BeanShell script which contains the listener logic.

You may be interested: