jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob van Bethlehem <>
Subject Again BeanShell
Date Thu, 04 Apr 2013 12:15:06 GMT
Dear users,

Previously I have been asking about this topic, but I can't quite wrap my head around it,
I'm sure I'm missing something obvious, but maybe it helps to be very specific. 
For my testscript I need to 'calculate' some parameter values that are to be sent to the application
I'm testing (ie: I'm creating HTTP Requests http://host?par1=val1&par2=val2 etc, and the
val1 and val2 need to be calculated based on a set of arguments)

From what I get from the manuals, it should be possible to script the calculating functions
in BeanShell in a single file, say 'myscripts.bsh', read these functions into JMeter once
at the start of the script, and call these functions with their appropriate arguments when
creating a HTTP Request:
* is this indeed a possible route to take? Or is there another way that is preferred?
* if yes: how to ensure that I read the BeanShell script only once at startup? In other words:
which component to add as a child of which component in the testplan? Or maybe is it better
to add a User Defined Variable to the test plain with the value of __BeanShell(source('myscripts.bsh'))?
* Once loaded: how to access a specific function from that file and how to pass arguments
to that function? I have seen examples that define a variable BSSCRIPT as ${__BeanShell(source('myscripts.bsh'))}
and then call this script as ${BSSCRIPT}. However, that would run the whole script, whereas
I wish to call a specific function _in_ that script, and on top of that, to pass variables
to that function 

To say the same in other words: in sect 19.5.13 on
there is a reference to the BeanShellFunction.bshrc, but it is not explained how to call for
instance the getprop() function that is defined there, and how to pass specific values to
that function. I'm looking for just how to achieve that, with the addition that I'd like my
testscript to explicitly read my BeanShell script file (once) at the start of the test instead
of configuring it as beanshell.function.init.

Hopefully I've been precize enough for people to point out what probably is quite obvious

Yours sincerely,
Jakob van Bethlehem
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message