Search code examples
javascriptingjmeterbeanshell

JMeter Beanshell share class definitions


is there a way to share class definitions between scripts created purely in jmeter? For instance if I had the following structure:

Thread1
     -BSSampler
     -BSSample2

How can I create a class in BSSampler and use that same class definition in BSSample2 explicitly? Or would I have to push the class definition out to a file and use

${__beanShell(source("filename.bsh"))}

to share the same class definitions? Right now it's saying it doesn't recognize the class definition because it's a different namespace.


Solution

  • You can declare your classes and functions in a bsh file that you reference in user.properties through:

    beanshell.server.file=../extras/startup.bsh

    You can have a look at this file in extras/startup.bsh