[Webtest] Using dbUnit XML files as properties fixtures?

Rob Manthey webtest@lists.canoo.com
Wed, 07 Jun 2006 15:16:38 +1000

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 file="./includes/dbUnitTestData.xml" />
  <target name="test">
      <testSpec name="test">
            <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! -->

typical dbUnit file structure:

<?xml version='1.0' encoding='UTF-8'?>
  <customerDetails customerID="1" customerName="Yaddayadda" />
  <thingDetails thingID="1" customerID="1" thingName="Yadda"
thingType="Yadda" />
  <thingDetails thingID="2" customerID="1" thingName="Yadda-Yadda"
thingType="Yadda" />

Thanks for any time you spend thinking about it.