[Webtest] DBUnit integrated to Canoo?

Ben Cox webtest@lists.canoo.com
Wed, 10 Apr 2002 10:41:05 -0700


Eric,
   While it would be simple enough to extend the testSpec to handle 
dbunit, it seemed far simpler not to!  Our rationale was that the dbunit 
task would probably be quite useful even when one isn't doing webtest. 
Since many of our webtests didn't necessarily need the database in any 
particular state, and we are thinking of creating other ant-driven 
testing frameworks (wanna help?), our decision to make it a separate 
task was clinched.
   We have basically copied the interface to the <sql> task from ant, 
trying to be sort of standard.  Basically, here's how we use it in practice:

   <target name="testRFQEndToEnd">
     <dbunit driver="${dbdriver}" url="${dburl} userid="${dbuserid}" 
password="${dbpassword}>
       <operation type="CLEAN_INSERT" src="../data/rfq/rfqData.xml"/>
     </dbunit>
     <testSpec name="Testing Entire RFQ Process">
       ...
   We expanded the "connection.properties" that came with webtest to 
include the ${dbXXX} properties needed to connect to the db, so you 
don't have to duplicate them each time.
   We had thought about using a <config> tag, like webtest does, which 
would have allowed you to include just the configuration via an entity 
reference (i.e. &dbconfig;) but decided to adhere to the mentality of 
the ant schema developers rather than the webtest schemas.   Our 
approach is to use properties in the file, which leaves the dbunit tag 
intact for clarity, though one could easily just include the first 
dbunit tag from a separate file:

   <target name="testRFQEndToEnd">
     &openDbUnit;
       <operation type="CLEAN_INSERT" src="../data/rfq/rfqData.xml"/>
     </dbunit>
     <testSpec name="Testing RFQ Process">
       ...


   Or, if you're frequently running the same operation from the same XML 
file, you can put the whole dbunit task in an include:

   <target name="testRFQEndToEnd">
     &myCleanInsert;
     <testSpec name="Testing RFQ Process">
       ...
   By the way, this only supports the FlatXML structure right now (I 
don't think we're going to bother with the old one)!
   Hope that helped,

     Ben && Tim

Eric Pugh wrote:
> Ben, Tim,
> 
> I think this task is very cool!  My one comment is that I currently have my
> various Canoo tests set up so that each target is a page, and each testSpec
> wraps up the navigation to that page, and then various checks on that
> page...
> 
> <target name="testWorkOrderList">
> 			<testSpec name="Test Workorder Listing Page">
> 
> I want to reset my database before each testSpec, so that the navigation to
> that page is always the same, and each page gets tested in isolation.  (more
> of a unit test for pages).  However, I still want to be able to do more
> System oriented tests where I test each page and how it affects other
> pages...
> 
> I was thinking of building in a property that executes the CLEAN_INSERT for
> each testSpec if a value is set...
> 
> Also, I wish I could configure a single <dbunit> task once, and not have to
> put the username etc everywhere in my buildfile...
> 
> Maybe some trickery with includes would help?
> 
> Eric
> 
> -----Original Message-----
> From: Ben Cox [mailto:ben@bjtechnics.com]
> Sent: Sunday, April 07, 2002 9:26 AM
> To: webtest@gate.canoo.com
> Subject: Re: [Webtest] DBUnit integrated to Canoo?
> 
> 
> David,
>    Well, my partner and I made a DBUnit task for Ant (a bit less than
> thoroughly commented, but it's not really that complicated!), which
> sounds like what you'd like.  We modelled it after the interface to the
> <sql> task in ant.  I've included the three Java files (including the
> test case), and the XML files required to run the test.  Please note a
> couple of things:
>     - the pktabledef.sql contains a MySQL dump of the simple test tables
>     - the classes need to go into package com.insourcery.ant.dbunit
>     - the setUp method in DBUnitTaskTester refers to the buildfile.xml
> without any path information, so keep that in mind.
> 
>    Feel free to get in touch if you see any improvements that would
> help, or if you just want to talk about the approach!
>    Enjoy,
> 
>      Ben Cox && Tim Ruppert
> 
> David Eric Pugh wrote:
>  > Has anyone integrated DBUnit into Canoo/httpUnit?
>  >
>  > I am testing a very database intensive app, and I want to after each
>  > <testSpec> to reset my database to a known state.  That way I can
> validate
>  > that all my forign keys and other database related setting work, and that
>  > they don't change under me!
>  >
>  > I think I need to create my own version of testSpec like testSpecDB
> that has
>  > as part of the setup and teardown resetting the database.
>  >
>  > Eric
>  >
>  >
>  > _______________________________________________
>  > WebTest mailing list
>  > WebTest@lists.canoo.com
>  > http://lists.canoo.com/mailman/listinfo/webtest
>  >
>  >
> 
> 
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
> 
>