[Webtest] Re: Memory Leak in Canoo

Nate Oster Nate Oster" <noster@numbersix.com
Mon, 4 Dec 2006 23:30:59 -0500


You can get around the limitation mentioned by George Bills, below, if
you include a standard setup file in each WebTest.  I don't think the
"ifStep" proposed earlier will work, since ifStep is itself a WebTest
step, not a native Ant task.

We use a common file called "WebTestSetup.xml"
It has one target, "doSetup", which declares the WebTest taskdef.
The last line in the doSetup target is:
	<property name=3D"alreadySetUp" value=3D"true"/>

Each WebTest XML file includes WebTestSetup.xml BEFORE any <webtest>
tags like this:
 	<import file=3D"[your path here]/WebTestSetup.xml"/> =20
THEN, each target in a WebTest XML file checks that the doSetup was
already run using Ant's depends attribute, like this:
	<target name=3D"Test No6" depends=3D"doSetUp">

As a result, you can run any of our WebTests from a command line, or
include it in an <antcall> suite.  No matter what, the Taskdef only gets
called ONCE. =20

Cheers!
Nate Oster

Date: Tue, 05 Dec 2006 13:54:31 +1100
From: George Bills <gbills@funnelback.com>
To: webtest@lists.canoo.com
Subject: Re: [Webtest] Re: Memory Leak in Canoo
Reply-To: webtest@lists.canoo.com
Reply-To: George Bills <gbills@funnelback.com>

I'm not sure if this is what you want, but you can pass properties from=20
Ant script to Ant script - most ways of calling an Ant script pass=20
properties from the parent to the child by default, and you can use=20
"inheritall=3D'true'" otherwise. I load "webtest.xml" once to define all =

the webtest stuff in my Ant test harness, and then that test harness=20
calls the tests. The tests themselves don't need to include the webtest=20
stuff at all - but that means that you can't run the tests individually=20
(because they'll be missing the webtest definitions). Hope that helps.

Rob Manthey wrote:
> (I'll probably be corrected shortly, but I think this is what Marc is=20
> getting at ...)
>
> This line (may have been slightly modified by me for my local=20
> conditions) must appear somewhere for webtest to work:
>  <taskdef file=3D"${canoowebtest.home}/webtestTaskdefs.properties"/>
>
> Anyway, each time it is included it instantiates a bunch of resources=20
> from the sounds of it and so it should only be run once per set of=20
> tests.  I guess this means wrapping it in some sort of conditional,=20
> but I have at the top of each file, so that's why (?) I accumulate=20
> memory usage when I hit "ant all" as the jvm is created once per ant=20
> session, but the webtest taskdef is called for every file.
>
> What is the optimal way to have the taskdef declared for each file,=20
> but so that it only gets called once if that file is referenced by=20
> wrapper files?   Such as:
>
>    <ifStep description=3D"Run Taskdef Once"=20
> unless=3D"${taskdefLoaded}=3D=3D'true'">
>        <taskdef
file=3D"${canoowebtest.home}/webtestTaskdefs.properties"/>
>        <property name=3D"taskdefLoaded" value=3D"true" />
>    </ifStep>