Thanks Mittie, I think I can use this. One clarification:
dataset.customerDetails[0].'@customerName'
What is the [0]? The first customerDetails record that appears in the
xml file?
Is there a way to select the record by reference to an attribute? ie:
[EMAIL PROTECTED]'0'].'@customerName'
Cleary this has the trap of returning a cursor (0-n elements), not
necessarily a single element, so that requires some handler I suppose?
Rob
on 07/06/06 16:15 Dierk Koenig said the following:
>Hi Rob,
>
>generally, I would use a little Groovy script to parse your
>XML and traverse the values via GPath.
>
> def file = new File('./includes/dbUnitTestData.xml')
> def dataset = new XmlParser().parse(file)
>
>and refer to it via e.g.
>
> dataset.customerDetails[0].'@customerName'
>
>Now there are at least to ways of using this approach, depending
>on what you want to do:
>- create a temporary properties file via Groovy before the WebTests
> are started and refer from WebTest to this file
> (if you need lots of this data and it is representable
> in the flat properties format)
>- in course of your tests, store xml values in WebTest properties
> by using little Groovy steps
> (the most flexible solution)
>
>cheers
>Mittie
>
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] Behalf Of Rob Manthey
>> Sent: Mittwoch, 7. Juni 2006 7:17
>> To: [email protected]
>> Subject: [Webtest] Using dbUnit XML files as properties fixtures?
>>
>>
>> Hi, I have a moderately bulky app that has some dbUnit xml test fixtures
>> already in place for unit testing, and I want to re-use them (or
>> similar) to load the db with data and then use webtest to look for that
>> data bubbling up. I currently have duplicated data in property files
>> that webtest looks for, so the db loads from xml files and webtest uses
>> .properties files - duplicated fixtures.
>>
>> Is it possible to have the webtests refer to the db unit files (similar
>> to the following) to fetch anticipated values for the webtests? Ideally
>> I'd like to just reference the dbUnit xml file as an include or
>> something (as per the referenced .properties file, but accepting and
>> parsing xml) and then reference the value as some sort of dotted
>> property with collection handling ... eg follows. Alternatively is
>> there an obvious framework combo that others use to have the same
>> fixtures both to preload the db and to then test the UI response?
>>
>> <?xml version="1.0" encoding="ISO-8859-1"?>
>> <!DOCTYPE project SYSTEM "./config/WebTest.dtd"[
>> <!ENTITY dbUnitTestData SYSTEM "./includes/dbUnitTestData.xml">
>> ]>
>> <project name="T3000ConfigRegionsTest" basedir="." default="all">
>>
>> <property>
>> &dbUnitTestData;
>> <property>
>> OR
>> <property file="./includes/dbUnitTestData.xml" />
>>
>> <target name="test">
>> <testSpec name="test">
>> &testconfig;
>> <steps>
>> <invoke url="http://Yadda.com" />
>> <verifyText text="Hi!
>> ${dataset.userDetails[thingID[2]].username}, welcome to Yadda.com" />
>> <!-- KABOOM - in case you've googled this and don't read
>> the context, this DOESN'T WORK at date of writing! -->
>> </steps>
>> </testSpec>
>> </target>
>>
>>
>> typical dbUnit file structure:
>>
>> <?xml version='1.0' encoding='UTF-8'?>
>> <dataset>
>> <customerDetails customerID="1" customerName="Yaddayadda" />
>> <thingDetails thingID="1" customerID="1" thingName="Yadda"
>> thingType="Yadda" />
>> <thingDetails thingID="2" customerID="1" thingName="Yadda-Yadda"
>> thingType="Yadda" />
>> </dataset>
>>
>> Thanks for any time you spend thinking about it.
>> Cheers
>> Rob
>>
>> _______________________________________________
>> WebTest mailing list
>> [email protected]
>> http://lists.canoo.com/mailman/listinfo/webtest
>_______________________________________________
>WebTest mailing list
>[email protected]
>http://lists.canoo.com/mailman/listinfo/webtest
>
>
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest