On 22/02/06, Bennett McElwee <[EMAIL PROTECTED]> wrote:
> Here's a useful tip for gaining finer control over your test plans. In
> particular, for including BeanShell code at arbitrary points in your
> tests. I'd love to hear of any similar or better ideas from other JMeter
> users.
>
> If you want to call BeanShell code before each execution of a Sampler,
> put the code into an external file and add a User Parameters
> Pre-Processor to the Sampler. In the Pre-Processor, check "Update Once
> Per Iteration", and add a single variable. The name of the variable can
> be anything, and the value ("User_1") should be
> ${__BeanShell(source("BeanShellSourceFile.bsh");,)}
> This allows you to do things such as recalculate variables within a
> loop.
>
> Calling BeanShell code after each execution of a Sampler is simpler.
> Just put the code into a BeanShell Assertion attached to the Sampler. I
> have used this for tweaking Sampler results before the listener writes
> them to a file.
Neat.
> These are the best approaches I have found. I initially thought of
> different approaches, but they weren't satisfactory:
> - The BeanShell Sampler would be useful, except that it adds an extra
> sample point in your results -- not so good if all you wanted it to do
> was calculate a variable or write a log message.
> - The User Defined Variables component could be used in the same manner
> as the User Parameters Pre-Processor, but it doesn't work in loops since
> it's not called every time.
BTW, there are some properties that can be used to define initialisation files:
beanshell.sampler.init=BeanShellSampler.bshrc
beanshell.function.init=BeanShellFunction.bshrc
beanshell.assertion.init=etc
These can be used to set up methods etc.
> What we really need is a BeanShell Pre-Processor and a BeanShell
> Post-Processor. These would be extremely useful. In fact, if we could
> get a BeanShell Timer and especially a BeanShell Listener too, JMeter
> would make a giant leap in usefulness and flexibility.
When BeanShell was added it was not clear how much use would be made of it.
You've shown that some simple code can be very effective.
I'll see about adding the other BSH elements.
I don't think these would be too difficult.
Thanks for the great suggestions.
BTW, feel free (others too) to update the JMeter Wiki with all these good ideas.
S.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]