You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Rob Schroder <ro...@manilla.com> on 2011/07/19 00:11:24 UTC
Reuse
Hi,
I've been using jmeter for a few months now and have accumulated several scripts (test plans). Many of these scripts have a series of steps that are identical, like logging in, logging off, or navigating high level links.
If the functionality around login changes, I have to change several scripts.
My question to the group is, how do you write your scripts with reuse in mind, using "logging in" as an example? I see that there's a ModuleController, but that works only within a test plan. Apologies if this is a naïve question.
Regards,
Rob
Re: Reuse
Posted by Rob Schroder <ro...@manilla.com>.
It turns out, with 2.4, you can save a fragment as a jmx file and include
it in other scripts. I just tested it and it works fine.
Rob Schroder l Performance Engineer l Office 415-625-0269 l Mobile:
415-205-4992 l Email: rob@manilla.com
On 7/18/11 3:36 PM, "Bruce Ide" <fl...@gmail.com> wrote:
> believe 2.4 behavior changes in some way, like they created a test
>element
>that you can put in the test plan to save a test fragment. Or something.
>I'm
>pretty sure you don't want to use a thread group. It would probably run
>in a
>separate thread in your test, which isn't really what you want.
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: Reuse
Posted by Bruce Ide <fl...@gmail.com>.
Hmm include controller, subject to numerous limitations, odd behaviors and
gotchas.
The first thing you're going to try with the include controller is put a
variable name somewhere in the controller input area. Maybe you want to
change the directory you're reading from. Maybe you want to vary the JMX
file you're reading from. Forget it, that won't work. At all. You can pass
JMeter a java property named includecontroller.prefix which can be used to
prepend a directory to the JMX file you're including.
Funnily enough I get better results in Hudson, since I can just subversion
checkout a test and any test fragments I want to include, and I can pass in
aforementioned prefix for an include directory in the job. I'm pondering the
possibility of a similar local test solution, which might work if I start
jmeter with Maven.
Other thing about the include controller is your mileage may vary... a LOT
depending on your version of jmeter. I'm stuck using 2.3.4, and in this
version you can't store the test you want to include in your test plan. It
has to be in the work bench. And the work bench does not get saved if you
hit ctrl-s, you have to save by selection manually whenever you want to
save.
I believe 2.4 behavior changes in some way, like they created a test element
that you can put in the test plan to save a test fragment. Or something. I'm
pretty sure you don't want to use a thread group. It would probably run in a
separate thread in your test, which isn't really what you want.
If you're good with Java, you could grab the jmeter source and modify the
include controller to not clone test plan and thread group nodes. That makes
the include controller a whole lot nicer to deal with. Its behavior can
still be quirky though.
Also keep in mind that variables are global. So an include does not act as a
function call. Any user defined variable data config elements you create in
an included module will overwrite any user defined variables you create in
your main test. I'm finding that it's a good idea to create one anyway, with
the variables the module needs, and then just disable it. That way they're
documented somewhere but don't interfere with your test.
You still can end up with a nasty variable explosion unless you're very
careful. At some point you realize that you have 4 different variables for
user name and that fixing it across 40 tests is not something you
particularly care to do. At that point you start wanting some sort of test
variable refactoring plugin. Or at least I do.
Not that I should be entirely pessimistic. Once you get it working, it does
actually work pretty well! It's one of those things where it seems like
you're going to make mistakes and just have to evolve good practices to deal
with the issues based on that. If you read this entire mail and decide to
use the include controller, I probably just saved you a week or two of that
sort of pain and suffering.
--
Bruce Ide
FlyingRhenquest@gmail.com