That's a very good method to script, another way is to use JSR223 sampler /Pre-Postprocessor and use any coding language to write your script (I prefer beanshell). You can call your script here and use different variables in parameters field which you can use in your script using args[] array and functions.
On 20 March 2013 11:58, Adrian Speteanu <[email protected]> wrote: > +1 for last part... > > Its a great method to setup your script file in the same element with all > the other static variables (so you can make all changes in a single place.) > > On Wed, Mar 20, 2013 at 2:34 AM, Stott, Charlie <[email protected]> wrote: > > > Hi Jakob, > > > > > * suppose I created a set of functions in an external script file - how > > to call > > > these from my script > > > > a) Read the file into a variable, then 'run' the variable using > > __javaScript function. > > > > Or > > > > b) Use the beanshell pre-processor and enter the filename in the 'Script > > file' field. > > > > > * for this same file: when running in GUI-mode, how to ensure the > JMeter > > > has seen these function definitions? > > > > Non-GUI uses the same test plan, not sure what problem you envisage here? > > > > > * Section 16.8 shortly has some 'best practices', where it is mentioned > > that I > > > can 'save a script as a variable' - what does that mean? How do I > achieve > > > that? My first guess was to copy/paste the function definition into the > > 'Value' > > > column of a User Defined Variable in the Test Plan, but somehow that > > > completely confuses the interpreter > > > > Almost.. > > > > For example, using User Defined Variables: > > > > Name: Value: > > SCRIPT_VAR if ("${SOME_VAR" != "") { > > vars.put("SOME_VAR", "value");} > > > > Then in another User Defined Variables element (scope means it won't run > > in the same element): > > > > Name: Value: > > RUN_SCRIPT ${__javaScript(${SCRIPT_VAR})} > > > > I tend to set the scripts early in my test plan, and then invoke them > > where necessary. > > > > Hope that helps. > > Charlie > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > -- ********************************************* Warm Regards Jitesh Thakur (PMP, ISEB, CSQA) http://in.linkedin.com/in/jiteshthakur M: 07943464906 *********************************************
