jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Sharing logic between thread groups
Date Thu, 13 Jun 2013 15:31:37 GMT
On 13 June 2013 13:54, Drach, Noa <Noa.Drach@ca.com> wrote:
> Hello all,
>
> In my test I have 5 thread groups - I was wondering if it is possible to share common
logic between the thread groups.
>
> Basically all of my tests have user id and organization id in the headers.
> For each thread that is running I am randomly selecting a user id in the range of 1-50
and organization id in the range of 1-100.
>
> All this is achieved by using a Bean Shell Preprocessor that is attached to each of the
samplers.

You can use a single PreProcessor at the top level of each Thread
Group and it will apply to all the samples.

> For each of the samplers this random editing of the header might also be accompanied
by some editing of the url as a result of the random user ID.
>
> By attaching a preprocessor to each sample I manage to do all this - but I was wondering
if there is some way to define some utility methods that I can call from each Bean Shell processor
and avoid repeating the logic.

You can define functions in a BeanShell startup script and call them
from the pre-processor.
Have a look at the sample .bshrc files in the bin directory.

Or just put the script in a file which can be re-used by multiple
pre-processors.

> For example:
> ...
> HeaderManager hm = sampler.getHeaderManager();
> callMySetHeaders(hm);
> // Do some specific code
>
> I know that it is possible to have custom functions - but my understanding is that they
only return a string - I am asking if there is a way to write more complex code.
>
> Thanks,
> Noa Drach
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Mime
View raw message