[Webtest] data-driven
Janno Kusman
webtest@lists.canoo.com
Fri, 30 Jan 2004 11:13:38 +0200
I don't know an easy way to do it, but here is one way to do it using
ANT optional script task:
test.xml>
<project name="test_zip" basedir="." default="prepare_data"/>
<property name="index" value="0"/>
<property file="zip_codes.properties"/>
<task name="prepare_data">
<script language="jpython" src="prepare_data.py"/>
<antcall target="webtest"/>
</task>
<task name="webtest" unless="end_of_data">
<testSpec name="ZIP test">
<config ../>
<steps>
<setinputfield stepid="set zip"
name="zip"
value="${zip}" />
...
</steps>
</testSpec>
<antcall target="prepare_data"/>
</task>
</project>
zip_codes.properties
zip1=12345
zip2=23456
...
zip17000=99999
prepare_data.py>
import sys
index = int(test_zip.getProperty("index"))
index = index + 1
#set ANT zip property
zip = test_zip.getProperty(test_zip.getProperty("zip"+str(index)))
test_zip.setProperty("index", str(index))
if(index > 17000):
test_zip.setProperty("end_of_data","1")
You may need to execute webtest task from script (using loop), because
my code is recursive and if one test fails, then no other tests are
executed.
BR,
Janno
Li, Dorothy wrote:
>This is my first time using webtest. I'm trying to test the same page using different input data, here, the input field is "zip code". The total number of the input data is a large amount, which is around 17,000. The data list can be stored in database or a file. I'm thinking of writing a loop using webTest, in the loop one zip code is read and result verified, then the next zip code. Is there any easy way to do this?
>
>
>
>