<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>CodeDependents &#187; database testing</title>
	<atom:link href="http://codedependents.com/tag/database-testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://codedependents.com</link>
	<description>Two Geeks Walk Into A Blog</description>
	<lastBuildDate>Mon, 30 Apr 2012 15:53:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='codedependents.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>CodeDependents &#187; database testing</title>
		<link>http://codedependents.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://codedependents.com/osd.xml" title="CodeDependents" />
	<atom:link rel='hub' href='http://codedependents.com/?pushpress=hub'/>
		<item>
		<title>Groovin&#039; Up Your Database Tests</title>
		<link>http://codedependents.com/2008/09/04/groovin-up-your-database-tests/</link>
		<comments>http://codedependents.com/2008/09/04/groovin-up-your-database-tests/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 16:02:33 +0000</pubDate>
		<dc:creator>Benjamin Darfler</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database testing]]></category>
		<category><![CDATA[dbunit]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://bdarfler.wordpress.com/?p=15</guid>
		<description><![CDATA[While TDD proclaims the gospel of fine grained tests and a healthy dose of mock objects, at some point, interaction with a database becomes inevitable.  Luckily, there is DbUnit to assist us.  DbUnit is a fantastic framework which allows for painless setup of database data sets, ensuring repeatable, self contained unit tests. However, there are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codedependents.com&#038;blog=7973493&#038;post=15&#038;subd=codedependents&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While TDD proclaims the gospel of fine grained tests and a healthy dose of mock objects, at some point, interaction with a database becomes inevitable.  Luckily, there is <a href="http://www.dbunit.org">DbUnit</a> to assist us.  DbUnit is a fantastic framework which allows for painless setup of database data sets, ensuring repeatable, self contained unit tests.  However, there are already <a href="http://www.dbunit.org/howto.html">plenty</a> <a href="http://www.onjava.com/pub/a/onjava/2004/01/21/dbunit.html">of</a> <a href="http://www.oreillynet.com/onjava/blog/2005/10/dbunit_made_easy.html">tutorials</a> on the subject.  Instead, what I want to talk about is the dark side of dbunit&#8230; xml.</p>
<p>Using dbunit on any reasonably sized project ends up with an explosion of xml data set files, even if care is taken to factor out common data sets and reuse them when possible.  For the longest time this seemed an unfortunate but necessary evil of using such an amazingly useful library, but that was before I attended the Northeast <a href="http://www.nofluffjuststuff.com">No Fluff Just Stuff</a> in April.  Before that point I had been interested in Groovy and was looking for places to add it to our code base (actually snuck it into a script that ran in the build) but I hadn&#8217;t really pondered the possibilities it provided.  However, NFJS was over flowing with talks and general love for Groovy.  Somewhere between the Groovy unit testing and the Groovy MOP talks it dawned on me.  Why not inline the xml using a Groovy builder?!</p>
<p>Groovy has this fantastic feature called <a href="http://groovy.codehaus.org/Builders">builders</a> which allows for very compact syntax to generate any sort of markup (html, xml, java swing, etc).  Of course the one we want to focus on is the <a href="http://groovy.codehaus.org/Creating+XML+using+Groovy's+MarkupBuilder">xml builder</a>.  By simply changing the file extension from .java to .groovy on the unit test we are already half way there.  After using Groovy&#8217;s syntax for creating xml we simply call .toString() on the underlying writer, wrap it in a new <a href="http://java.sun.com/javase/6/docs/api/java/io/StringReader.html">StringReader</a>() and then pass create a new <a href="http://www.dbunit.org/apidocs/org/dbunit/dataset/xml/FlatXmlDataSet.html">FlatXmlDataSet</a>() with the reader as the only constructor argument.</p>
<p>If you are using <a href="http://ant.apache.org/">Ant</a> for your build you can simply wire up the <a href="http://groovy.codehaus.org/The+groovyc+Ant+Task">groovyc</a> task to compile all of your groovy tests and then call <a href="http://ant.apache.org/manual/OptionalTasks/junit.html">junit</a> on the .class files.  If you want to get this working in Eclipse, best of luck, I was able to kinda get it working under windows xp but now that I have switched to os x the groovy plugin screams bloody murder with 64-bit java under os x in Eclipse.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codedependents.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codedependents.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codedependents.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codedependents.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codedependents.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codedependents.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codedependents.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codedependents.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codedependents.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codedependents.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codedependents.com&#038;blog=7973493&#038;post=15&#038;subd=codedependents&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codedependents.com/2008/09/04/groovin-up-your-database-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e0132e931569bbd7d6ad6ef56a6f11db?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bdarfler</media:title>
		</media:content>
	</item>
	</channel>
</rss>
