Marc,

 

Thanks for this helpful response.  This is indeed exactly what I was looking
for.  Unfortunately, I am having difficulty still.  When I iterate over the
<macrodef> steps with <repeat>, the properties are not expanded to their
actual values, but instead are placed in the form literally, i.e.
${prop.0.fld}, instead of "value".  In other words, where I am expecting
"John" to be placed in my first name field, instead I get the unexpanded
property ${user.0.first_name}.  Furthermore, the repeat counter does not
seem to increment.  On subsequent loop iterations, the property
${user.0.first_name}, not ${user.1.first_name} is placed in the form field.
I have also tried using value="[EMAIL PROTECTED]", but the results
are the same.

 

Here is the code for my test:

 

<?xml version="1.0"?>

<!DOCTYPE project SYSTEM "../Config/WebTest.dtd"[

  <!ENTITY config     SYSTEM "../Config/config.xml">

  <!ENTITY assertNoError SYSTEM "../modules/assertNoError.xml">

  <!ENTITY login     SYSTEM "../modules/Loginsteps.xml">

  <!ENTITY addUsers SYSTEM "../modules/userAddMultiple.xml"> ]>

 

<project name="UserTest" basedir="." default="UserTest">

  <property name="webtest.home" location="c:/projects/java/canoo" />

  <property name="apptest.home"
location="c:/Projects/PhpWebProjects/sunergeo/UnitTests/canoo" />

 

  <property file="${apptest.home}/properties/user.properties"/>

  <import file="${webtest.home}/lib/taskdef.xml"/>

 

  <macrodef name="addUser">

    <attribute name="index" description="the current loop index"/>

    <sequential>

      <setInputField name="First" value="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <setInputField name="Last" value="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <setInputField name="Address1" value="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <setInputField name="Address2" value="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <setInputField name="City" value="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <setInputField name="State" value="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <setInputField name="Zip" value="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <setInputField name="Country" value="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <setCheckbox name="CanEmail" checked="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <setCheckbox name="CanNewsletter"
checked="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <setInputField name="Email" value="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <setInputField name="password" value="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <setInputField name="ConfirmPass" value="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

      <clickButton name="submit" description="Click the submit button to add
the user"/>

      &assertNoError;

    </sequential>

  </macrodef>

 

  <target name="UserTest" description="Creating user records for subsequent
tests">

    <webtest name="UserTest">

      &config;

      <steps>

        <repeat count="1">

          <addUser index="#{count}" />

        </repeat>

      </steps>

    </webtest>

  </target>

</project>

 

============================================================================
==============================================

 

The properties file looks like this:

 

user.0.first_name=Bill

user.0.last_name=Smith

user.0.address1=101 W 1st

user.0.address2=

user.0.city=Tyler

user.0.state=TX

user.0.zip=75701

user.0.country=United States

user.0.can_email=true

user.0.can_newsletter=true

[EMAIL PROTECTED]

user.0.password=fuzzyduck

 

Any ideas on what I've done wrong?

 

Shawn Bradley

President, Sunergeo Systems, Inc.

www.sunergeosystems.com

 

 

-----Original Message-----

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Marc Guillemot

Sent: Tuesday, January 02, 2007 2:10 AM

To: [email protected]

Subject: Re: [Webtest] Testing with lists of input data

 

Hi Shawn,

 

if I correctly understand, you have properties like

 

categ.name.0=first categ

categ.name.1=second categ

...

 

and want to iterate over this categs. Right?

 

The repeat loop provides the counter variable but nested properties
evaluation like ${categ.name.#{counter}} is currently not available. The
workaround is to externalize the body of your repeat loop in a macro:

 

<macrodef name="myRepeatBody">

   <attribute name="index" description="the current loop index"/>

   <sequentials>

     <setInputField forLabel="Category" value="[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> "/>

     ...

   </sequentials>

</macrodef>

 

and

<webtest ...>

   ...

   <repeat count="...">

     <myRepeatBody index="#{counter}"/>

   </repeat>

</webtest>

 

Happy Testing,

Marc.

 

Shawn Bradley wrote:

> I am fairly new to WebTest, but so far, I've been able to accomplish 

> just about everything I need to.  However, I am stuck at this 

> particular requirement.

> 

>  

> 

> Our app builds expense reports, and each expense entry references an 

> expense category.  I am writing tests to exercise the expense category 

> maintenance portion of the app.  What I want to do is create a 

> property file that contains the parameters for a dozen or so expense
categories.

> I then need my WebTest case to create each of these categories in a 

> loop, using <repeat> or some other construct.  I DON'T want to have to 

> create the same XML instructions a dozen or more times to construct 

> the categories in a linear fashion.

> 

>  

> 

> I have spent hours digging through the newsgroup and mailing list 

> archives, and I cannot find an example similar to what I am trying to 

> do.  This seems like such a common task to me - surely someone else 

> has had a similar requirement.  How do I accomplish this?

> 

>  

> 

> Thanks,

> 

>  

> 

>  

> 

> Shawn Bradley

> 

> President, Sunergeo Systems, Inc.

> 

> www.sunergeosystems.com

> 

>  

> 

 

 

Reply via email to