Pre-requisite:
Inside JMeter bin folder, I have edited BeanShellFunction.bshrc
file to add my function as follows
String getMyString()
{
return "MyString";
}
I have enabled the BeanShellFunction.bshrc
from jmeter.properties
file as
beanshell.function.init = BeanShellFunction.bshrc
When I use the following syntax to call function it works fine.
${__BeanShell(getMyString())}
Question:
How can I call the same function from BeanShell Programs like PreProcessor, PostProcessor, Assertion, etc.?
Analysis:
I tried with following but no luck:
String myStr = getMyString();
It gives an error as:
Assertion error: true
Assertion failure: false
Assertion failure message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: `` String myStr = getMyString(); print("MyStr: "+myStr);'' : Typed variable declaration : Command not found: getMyString()