0
votes

Here below are my scenario:

I am using JMeter to generate loads I have to read multiple .csv files and extracting values, then add some logic to it and then pass this data to Java functions (we have a jars files for that) I am using a BeanShell script. But I don't want to write all the code into one file. As file become a very big and hard to maintain.

Query: Is there any way to write these functions in multiple beanshell script? Query: Is that possible to call these function written in different beanshell scripts?

Can you provide a sample code for this?

This is what I am trying to do, below code is just for an example:

In 1st beanshell file, I defined a function

int sum (int a, int b)
{
      return a+b;
}

In 2nd beanshell file I want to call this function

int j = sum(2,3);
log.info("sum-------------"+j);
1

1 Answers

0
votes
  • Edit jmeter/bin/user.properties file and add this:

beanshell.sampler.init=BeanshellCommong.bshrc

  • Put your function in the BeanshellCommong.bshrc file
  • Put this file in jmeter/bin folder
  • Restart jmeter

But note that it's better to use groovy using:

groovy.utilities=bin/utility.groovy

See: