Each occurrence of a function in a test plan is a separate instance.

Make sure that you only have one function call; you can put this in a
user parameters pre-processor so that each sampler gets a new value.

However, I would probably not do it this way; it's a waste of
resources to do the randomisation at run-time if it can be avoided.
Also, if the file is big, it will take a lot of memory.

I'd create a pre-randomised file and use CSV Dataset or
__StringFromFile() to read it.

On 26/10/2007, CharekC <[EMAIL PROTECTED]> wrote:
>
> I've been looking at beanshell to get random csv file values.
> I have the following code:
>
> ArrayList csv_array=null;
>
> String getCSV_Value() {
>
>        if (csv_array==null)
>                // initialize csv_array from file
>
>        if (csv_array.size()>0)
>                //return random value from csv_array
>        else
>                // return error_value
>
> }
>
> I'm running into the problem where each call of
> ${__BeanShell(getCSV_Value())} initializes the csv_array.
> I've tried the following:
> 1. renamed getCSV_Value() to execute()
> 2. tried public static ArrayList csv_array=null;
> 3. Placed the code and referenced it in jmeter.properties
> beanshell.function.init=
> beanshell.init.file=
>
> So how can one make csv_array global and the getCSV_Value() method
> synchronized? (Jmeter 2.3RC4)
>
> Thanks
> --
> View this message in context: 
> http://www.nabble.com/Beanshell-to-get-random-csv-value-tf4698152.html#a13430100
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to