Skip to content

__BeanShell

JMeter __BeanShell function reference: syntax, parameters, and practical examples for parameterizing test plans with dynamic values.

Difficulty
intermediate
Guide type
reference
Estimated read time
1 min read
Last verified version
Verified JMeter 5.6

Also documented in context in the full Functions and Variables reference.

The BeanShell function evaluates the script passed to it, and returns the result.

For full details on using BeanShell, please see the BeanShell web-site at http://www.beanshell.org/

A single instance of a function may be called from multiple threads. However the function execute() method is synchronised.

If the property โ€œbeanshell.function.initโ€ is defined, it is passed to the Interpreter as the name of a sourced file. This can be used to define common methods and variables. There is a sample init file in the bin directory: BeanShellFunction.bshrc.

The following variables are set before the script is executed:

(*) means that this is set before the init file, if any, is processed. Other variables vary from invocation to invocation.

NameRequiredDescription
BeanShell scriptYesA beanshell script (not a file name)
Name of variableNoA reference name for reusing the value computed by this function.

Example:

\$\{__BeanShell(123*456)\} : returns 56088

\$\{__BeanShell(source("function.bsh"))\} : processes the script in function.bsh

On this page