[Webtest] Modularizing tests
Dirk Olmes
webtest@lists.canoo.com
Tue, 15 Apr 2003 15:57:27 +0200
Hi,
I've read the chapter about property usage in the WebTest documentation
but what's mentioned there seems to be only part of what you can
accomplish with WebTest and ant.
Here's what I try to do:
I have a stateful web app (i.e. one that has a session identifier) where
I need to fill out a certain form more than once, each time with
different values.
Filling out the form seems to be perfectly reusable:
<setinputfield stepid="..." name="${field1}" value="AA"/>
<setinputfield stepid="..." name="${field2}" value="123"/>
<clickbutton stepid="..." label="goForIt"/>
However, since ant allows the setting of properties only once the way to
go seems to be the "ant" or "antcall" tasks.
This is where the trouble starts: each WebTest task needs to include the
full configuration/testspec which internally results in the creation of
a new WebConversation. This breaks my app since I have to have a
constant clickpath through the application.
I've hacked around in WebTest a bit so that a WebConversation will be
created only once and all subsequent testspecs just reuse that WC. So
now I can do something like:
<target name="CreateAdmin">
<ant antfile="Login.xml">
<property name="username" value="admin"/>
<property name="password" value="admin"/>
</ant>
<ant antfile="GotoUserManagement.xml"/>
<ant antfile="FillOutUserCreationForm.xml">
<property name="firstname" value="Willi"/>
<property name="lastname" value="Wusel"/>
<property name="department" value="Testabteilung"/>
<property name="loginname" value="willi"/>
<property name="password" value="willi"/>
</ant>
<antcall target="AssignAdminRight"/>
</target>
and each ant file specifies a full testspec like:
<target name="Login">
<testSpec name="Login">
&config;
<steps>
<setinputfield name="username" value="${username}" />
<setinputfield name="password" value="${password}" />
<clickbutton name="login" />
</steps>
</testSpec>
</target>
Is this anyone interested in a more generic solution, i.e. the config
tag allowing something like <config reusewebconversation="true"/>? Would
this be included into the distro? Where do I have to submit the patches?
-dirk