<?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>Code Adept &#187; tdd</title>
	<atom:link href="http://blog.code-adept.com/tag/tdd/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.code-adept.com</link>
	<description>Random thoughts on Agile development and other things geeky.</description>
	<lastBuildDate>Thu, 09 Feb 2012 01:15:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.code-adept.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Code Adept &#187; tdd</title>
		<link>http://blog.code-adept.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.code-adept.com/osd.xml" title="Code Adept" />
	<atom:link rel='hub' href='http://blog.code-adept.com/?pushpress=hub'/>
		<item>
		<title>Code Retreat GR Recap</title>
		<link>http://blog.code-adept.com/2010/02/17/code-retreat-gr-recap/</link>
		<comments>http://blog.code-adept.com/2010/02/17/code-retreat-gr-recap/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 22:12:01 +0000</pubDate>
		<dc:creator>Jeremy Anderson</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[code retreat]]></category>
		<category><![CDATA[craftsmanship]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[kata]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[test first]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://blog.code-adept.com/?p=154</guid>
		<description><![CDATA[On February 6th I hosted the first Code Retreat to hit West Michigan, and we really couldn&#8217;t have asked for a nicer day for a Code Retreat. Well, maybe a little bit warmer weather, but hey, it&#8217;s February in Michigan, what do you expect? So after a quick stop at Panera Bread to get some bagels, scones [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.code-adept.com&amp;blog=2511053&amp;post=154&amp;subd=codeadept&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>On February 6th <a title="Jeremy Anderson" href="http://www.atomicobject.com/pages/Jeremy+Anderson/">I</a> hosted the first <a title="Code Retreat" href="http://coderetreat.ning.com/">Code Retreat</a> to hit West Michigan, and we really couldn&#8217;t have asked for a nicer day for a Code Retreat. Well, maybe a little bit warmer weather, but hey, it&#8217;s February in Michigan, what do you expect? So after a quick stop at Panera Bread to get some bagels, scones and muffins, I made my way down to <a title="Our Historic Building" href="http://www.atomicobject.com/pages/Our+Historic+Building">Atomic Object HQ</a> to start the coffee brewing in preparation for the attendees. Shortly after sunrise, <a title="Agile Shrugged" href="http://agileshrugged.com/blog/">Nayan Hajratwala</a> showed up to help with any last minute preparations before everyone else showed up.<br />
<span id="more-154"></span><br />
<img title="Code Retreaters pairing on Game of Life" src="http://spin.atomicobject.com/assets/2010/2/16/63951982.jpg" alt="Code Retreat GR" /></p>
<p>Soon about 20 people from all parts of the region had showed up to practice TDD and learn with each other, including one guy who came all the way down from Marquette, MI just to attend. He officially got the &#8220;I traveled the furthest&#8221; award for the day. We were also joined by <a title="XProgramming" href="http://xprogramming.com/index.php">Ron Jeffries</a>and <a title="Hendrickson XP" href="http://www.hendricksonxp.com/">Chet Hendrickson</a>, who had agreed to come and be my professional trouble makers for the day. Shortly after 9:00, once everyone had been sufficiently caffeinated, we decided to get started. One of the attendees had mentioned something about <a title="Corey Haines" href="http://coreyhaines.com/">Corey Haines</a> putting together a<a title="coreyhaines / practice_game_of_life @ github" href="http://github.com/coreyhaines/practice_game_of_life">set of Cucumber features</a> at one of the previous Code Retreats in Chicago, so some of the pairs decided to give that a whirl. After some yak shaving we managed to get through the first iteration of the morning and retrospected on what happened and continued on into the second iteration of the day.</p>
<p>My original plan was to just sort of float around, help facilitate, and observe everyone else pairing, however when I noticed Ron Jeffries didn&#8217;t have a pair for the second iteration, I took the opportunity to pair with him. Neither of us knew Cucumber very well, so we decided to give that a whirl. If ever you get the chance to pair with either Ron or Chet, don&#8217;t think twice about it, just do it. Ron had at one point in the day managed to &#8211; as one participant described &#8220;&#8230;[kick his] BDD mindset a bit out of place. . . &#8220;</p>
<p>Before we knew it, lunch was upon us. It turns out that Corey Haines was hosting another Code Retreat in Seattle that day, so we fired up Skype and greeted our fellow Code Retreaters on the west coast as they were just getting ready to start for the day. Then we all proceeded to enjoy the taco bar that had been delivered for lunch and continued to retrospect on the days events so far. When we were all finished stuffing our faces with Qdoba, Mike Sweiton and myself gave our participants a quick tour of Atomic Object HQ, showing off our open space, <a title="Information Radiators" href="http://spin.atomicobject.com/2010/02/08/information-radiators">stoplight</a>, CI server, and our embedded projects workbench.</p>
<p>Now that our food had a chance to settle, it was back to pairing for a few more iterations of Conway&#8217;s Game of Life. After one of the afternoon retrospectives, for a little bit of a distraction, we watched a video of someone implementing <a title="Game of Life in APL" href="http://www.youtube.com/watch?v=a9xAKttWgP4">Conway&#8217;s Game of Life in APL</a>. This was spawned by an email thread that circulated right before the Code Retreat about how to implement the<a title="Game of Life in single line of APL" href="http://www.dyalog.com/dfnsdws/c_life.htm">Game of Life in a single line of APL</a>, which still blows my mind.</p>
<p>Finally, by the time the end of the day had finally arrived, we had lost a few of our fellow coders and we were ready to call it a day. Those of us who were still left standing at the end of the day took a walk around the corner to <a title="The Green Well" href="http://thegreenwell.com/">The Green Well</a>, one of the many local establishments in the Eastown area, for some much needed unwinding. We continued to retrospect on the day&#8217;s happenings over a few local microbrews and some delicious items from the menu. All in all I would have to say this was a successful Code Retreat. Everyone had a great time, we all got to pair program with some great folks we wouldn&#8217;t normally get to pair with, and &#8211; most importantly &#8211; learning happened. Though many of the Code Retreats in the past have used Java as their language of choice, in my opinion I think using Ruby for this Code Retreat was the right choice. It afforded us much less yak shaving than would have probably been necessary had we been using Java. I&#8217;m looking forward to hosting another Code Retreat later this year when the weather is a little warmer, and hopefully attending the upcoming <a title="Code Retreat Philadelphia" href="http://coderetreat.ning.com/xn/detail/2712512:Event:4161?xg_source=activity">Code Retreat being hosted in Philadelphia</a> by <a title="Beards and Keyboards" href="http://sebastianlab.com/">Sebastian Hermida</a>.</p>
<br /> Tagged: <a href='http://blog.code-adept.com/tag/agile/'>agile</a>, <a href='http://blog.code-adept.com/tag/code-retreat/'>code retreat</a>, <a href='http://blog.code-adept.com/tag/craftsmanship/'>craftsmanship</a>, <a href='http://blog.code-adept.com/tag/cucumber/'>cucumber</a>, <a href='http://blog.code-adept.com/tag/kata/'>kata</a>, <a href='http://blog.code-adept.com/tag/ruby/'>Ruby</a>, <a href='http://blog.code-adept.com/tag/tdd/'>tdd</a>, <a href='http://blog.code-adept.com/tag/test-first/'>test first</a>, <a href='http://blog.code-adept.com/tag/testing/'>testing</a>, <a href='http://blog.code-adept.com/tag/unit-testing/'>unit testing</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeadept.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeadept.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeadept.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeadept.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeadept.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeadept.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeadept.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeadept.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeadept.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeadept.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeadept.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeadept.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeadept.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeadept.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.code-adept.com&amp;blog=2511053&amp;post=154&amp;subd=codeadept&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.code-adept.com/2010/02/17/code-retreat-gr-recap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/611c688725819bb23742a714a9c33dfe?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jeremy</media:title>
		</media:content>

		<media:content url="http://spin.atomicobject.com/assets/2010/2/16/63951982.jpg" medium="image">
			<media:title type="html">Code Retreaters pairing on Game of Life</media:title>
		</media:content>
	</item>
		<item>
		<title>Testing Legacy Code</title>
		<link>http://blog.code-adept.com/2008/10/31/testing-legacy-code/</link>
		<comments>http://blog.code-adept.com/2008/10/31/testing-legacy-code/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 17:05:35 +0000</pubDate>
		<dc:creator>Jeremy Anderson</dc:creator>
				<category><![CDATA[Rant]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://codeadept.wordpress.com/?p=70</guid>
		<description><![CDATA[The company I work for, Pillar Technology, recently created this really slick tool called Verde to generate unit tests for legacy code.  I have to admit at first I was very skeptical as I had seen some pretty ugly legacy code out there.  To make sure we&#8217;re on the same page here I personally define [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.code-adept.com&amp;blog=2511053&amp;post=70&amp;subd=codeadept&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The company I work for, <a href="http://pillartechnology.com" target="_blank">Pillar Technology</a>, recently created this really slick tool called <a href="http://frogyourcode.com" target="_blank">Verde</a> to generate unit tests for legacy code.  I have to admit at first I was very skeptical as I had seen some pretty ugly legacy code out there.  To make sure we&#8217;re on the same page here I personally define &#8220;Legacy Code&#8221; just as Michael Feathers does in his article &#8220;<a href="http://www.objectmentor.com/resources/articles/WorkingEffectivelyWithLegacyCode.pdf" target="_blank">Working Effectively with Legacy Code</a>&#8221; as code that has a lack of tests around it.  So by this definition code that was written even last week could conceivably be considered &#8220;Legacy&#8221; if there is a lack of tests.</p>
<p>So to get to the point, now that I&#8217;ve had some time to look at the tool, I&#8217;m rather pleasantly surprised.  I&#8217;ve seen this tool in action, and generate a bunch of integration tests for a service layer for an application, which will allow you to refactor confidently.  Jump over to the website (<a href="http://frogyourcode.com" target="_blank">http://frogyourcode.com</a>) and check it out.</p>
<br /> Tagged: agile, tdd, testing <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeadept.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeadept.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeadept.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeadept.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeadept.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeadept.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeadept.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeadept.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeadept.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeadept.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeadept.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeadept.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeadept.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeadept.wordpress.com/70/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.code-adept.com&amp;blog=2511053&amp;post=70&amp;subd=codeadept&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.code-adept.com/2008/10/31/testing-legacy-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/611c688725819bb23742a714a9c33dfe?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jeremy</media:title>
		</media:content>
	</item>
		<item>
		<title>Refactoring to RIAs &#8211; Agile 2008</title>
		<link>http://blog.code-adept.com/2008/01/30/refactoring-to-rias-agile-2008/</link>
		<comments>http://blog.code-adept.com/2008/01/30/refactoring-to-rias-agile-2008/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 19:23:14 +0000</pubDate>
		<dc:creator>Jeremy Anderson</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[agile2008]]></category>
		<category><![CDATA[continuous integration]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://blog.code-adept.com/?p=27</guid>
		<description><![CDATA[BJ and I have decided to throw our hat into the ring and submitted a session proposal to the Agile 2008 conference. You can read about it and comment on it on the Agile 2008 submission site here (http://submissions.agile2008.org/node/1676), or I&#8217;ve copied the summary below. In 2002 Macromedia used the term “Rich Internet Applications” (RIA) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.code-adept.com&amp;blog=2511053&amp;post=27&amp;subd=codeadept&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>BJ and I have decided to throw our hat into the ring and submitted a session proposal to the Agile 2008 conference.  You can read about it and comment on it on the Agile 2008 submission site here (<a href="http://submissions.agile2008.org/node/1676" target="_blank">http://submissions.agile2008.org/node/1676</a>), or I&#8217;ve copied the summary below.</p>
<blockquote><p>In 2002 Macromedia used the term “Rich Internet Applications” (RIA) to  describe the next generation of web applications that have all of the benefits  of a traditional desktop application, with the flexibility of being deployed via  the Internet.</p>
<p>However, it’s 2008 and RIA has not been able to penetrate the business  application sector with any real success. The old days of RIA are history.  (Maintenance nightmares, weird or no unit testing, and little friendliness  toward other agile developer practices.)</p>
<p><span id="more-27"></span></p>
<p>With a RIA framework like Adobe Flex it’s now possible to unit test RIA  applications and even write tests first. It’s possible to connect up to a CI  server just like server-side code and pick up coverage stats. It’s possible to  evolve a simple design incrementally and emergently.</p>
<p>The speakers will model how to make standard agile development practices work  in the RIA world: Refactoring, Test First Design, Simple Design, Continuous  Design, and Continuous Integration &amp; Automated Builds.</p>
<p>The bottom line is many businesses have invested much time and money into  their existing applications and their staff. For this reason, this session will  guide the attendees on how to refactor an existing web application with familiar  server-side technologies. We’ll show how to integrate Flex into existing  applications in order to build a next generation application that will delight  users.</p>
<p>Rather than trying to teach the basics of Flex, the speakers will demonstrate  how to develop robust applications leveraging the Flex framework in concert with  enterprise technologies like Java. These applications can be deployed not only  to the web but also to the desktop using the Adobe Integrated Runtime (AIR).</p>
<p class="field field-type-text field-field-processmechanics">&nbsp;</p>
<p class="field-label">Process/Mechanics</p>
<p class="field-items">&nbsp;</p>
<p class="field-item">Refactoring to RIA’s will be a demonstrative (tutorial-like) session geared  towards Java developers that would like to refactor existing applications in an  agile way. Test First, CI, and other friendly agile practices will be key in  making this possible.</p>
<p>The session will consist of live code and practice demonstrations leveraging  an already existing application. Requirements for creating a new rich client  interface will be explored and code will be refactored in a Red/Green/Refactor  manner.</p></blockquote>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codeadept.wordpress.com/27/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codeadept.wordpress.com/27/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeadept.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeadept.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeadept.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeadept.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeadept.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeadept.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeadept.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeadept.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeadept.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeadept.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeadept.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeadept.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeadept.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeadept.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.code-adept.com&amp;blog=2511053&amp;post=27&amp;subd=codeadept&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.code-adept.com/2008/01/30/refactoring-to-rias-agile-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/611c688725819bb23742a714a9c33dfe?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jeremy</media:title>
		</media:content>
	</item>
		<item>
		<title>Unit Testing JSP Custom Tags</title>
		<link>http://blog.code-adept.com/2008/01/25/unit-testing-jsp-custom-tags/</link>
		<comments>http://blog.code-adept.com/2008/01/25/unit-testing-jsp-custom-tags/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 13:43:40 +0000</pubDate>
		<dc:creator>Jeremy Anderson</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[custom tags]]></category>
		<category><![CDATA[JSP]]></category>
		<category><![CDATA[mock testing]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[test first]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://blog.code-adept.com/?p=26</guid>
		<description><![CDATA[Testing J2EE components has always been a difficult task, which is probably why I see so many web projects that have few tests written for the web layer or sometimes none at all. Late last year Spring announced the release of Spring 2.5 , with some nice additions to the suite of mock testing objects [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.code-adept.com&amp;blog=2511053&amp;post=26&amp;subd=codeadept&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Testing J2EE components has always been a difficult task, which is probably why I see so many web projects that have few tests written for the web layer or sometimes none at all. Late last year Spring announced the release of Spring 2.5 , with some nice additions to the suite of mock testing objects for unit testing web components. That&#8217;s right unit testing web components, not in container testing. So like any good agile programmer let&#8217;s start with the test first.<span id="more-26"></span></p>
<p><pre class="brush: java;">

public class SomeCustomTagTest extends TestCase {

    private SomeServiceInterface mockService;
    private SomeCustomTag someCustomTag;
    private MockServletContext mockServletContext;
    private MockPageContext mockPageContext;
    private WebApplicationContext mockWebApplicationContext;

    protected void setUp() throws Exception {
        super.setUp();
        // Create the mock servlet context
        mockServletContext = new MockServletContext();

        // Create the mock Spring Context so that we can mock out the calls to getBean in the custom tag
        // Then add the Spring Context to the Servlet Context
        mockWebApplicationContext = createMock(WebApplicationContext.class);
        mockServletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
                                        mockWebApplicationContext);

        // Create the MockPageContext passing in the mock servlet context created above
        mockPageContext = new MockPageContext(mockServletContext);

        // Create the mock service object using it's interface
        mockService = createMock(SomeServiceInterface.class);

        // Create an instance of the custom tag we want to test
        // set it's PageContext to the MockPageContext we created above
        someCustomTag = new SomeCustomTag();
        someCustomTag.setPageContext(mockPageContext);

        // Whenever you make a call to the doStartTag() method on the custom tag it calls getServletContext()
        // on the WebApplicationContext.  So to avoid having to put this expect statement in every test
        // I've included it in the setUp()
        expect(mockWebApplicationContext.getServletContext()).andReturn(mockServletContext).anyTimes();
    }

}</pre><br />
Some things you&#8217;ll notice in the setUp() method are that we&#8217;re creating a mock for the Spring Context. Since I don&#8217;t know of any way to have Spring inject dependencies into the custom tag, we&#8217;ll be getting a WebApplicationContext object from the container to get our beans from Spring. This mock allows us to fake calls to getBean() and return our mock service objects so we can unit test the custom tag without relying on external dependencies.<br />
Now in order to get this test to compile we need to create the custom tag class. You&#8217;ll notice that we&#8217;re extending the RequestContextAwareTag class instead of TagSupport. The RequestContextAwareTag class is a Spring helper class that gives us some convenience methods for getting the WebApplicationContext among other things. You&#8217;ll also see that the method we need to implement is called doStartTagInternal() instead of doStartTag().<br />
<pre class="brush: java;">

public class SomeCustomTag extends RequestContextAwareTag {

    protected int doStartTagInternal() throws Exception {

        // put some business logic here

        return SKIP_BODY;
    }

}</pre><br />
Now let&#8217;s write a failing test. Back in the unit test lets add a test method and a couple of helper methods for the mock objects.<br />
<pre class="brush: java;">

public void testDoStartTag() throws Exception{
    String param = &quot;Jeremy&quot;;
    String expectedOutput = &quot;Hello, &quot; + param;

    replayAllMocks();

    someCustomTag.setUserName(param);
    int tagReturnValue = someCustomTag.doStartTag();
    String output = ((MockHttpServletResponse) mockPageContext.getResponse()).getContentAsString();

    assertEquals(&quot;Tag should return 'SKIP_BODY'&quot;, TagSupport.SKIP_BODY, tagReturnValue);
    assertEquals(&quot;Output should be 'Hello, Jeremy'&quot;, expectedOutput, output);

    verifyAllMocks();
}

private void replayAllMocks() {
	replay(mockWebApplicationContext);
	replay(mockCompanyQuery);
}

private void verifyAllMocks() {
	verify(mockWebApplicationContext);
	verify(mockCompanyQuery);
} 

</pre><br />
In order to get the test to compile, you&#8217;ll need to modify the SomeCustomTag class to have a setter method for a userName parameter.  We would like our custom tag to say &#8220;Hello&#8221; to a username that is passed in, so let&#8217;s implement the behavior we are trying to accomplish.<br />
<pre class="brush: java;">

public class SomeCustomTag extends RequestContextAwareTag {

    private String userName;

    // A setter for an attribute that will be set in the custom tag
    public void userName(String userName) {
        this.userName = userName;
    }

    protected int doStartTagInternal() throws Exception {

        pageContext.getOut().print(&quot;Hello, &quot; + userName);

        return SKIP_BODY;
    }

}

</pre><br />
Next we would like to get the users full name from our Spring service.  So in order to do that we need to tell the mockWebApplicationContext to return a mock of our service so we can unit test this in isolation.  We also need to tell our mock service that we expect a call to getFullName() and what to return from this call.  So modify our test method to resemble the following.<br />
<pre class="brush: java;">

public void testDoStartTag() throws Exception{
    String param = &quot;Jeremy&quot;;
    String fullName = &quot;Jeremy Anderson&quot;;
    String expectedOutput = &quot;Hello, &quot; + fullName;

    expect(mockWebApplicationContext.getBean(&quot;someService&quot;)).andReturn(mockService);
    expect(someService.getFullName(param)).andReturn(fullName);
    replayAllMocks();

    someCustomTag.setUserName(param);
    int tagReturnValue = someCustomTag.doStartTag();
    String output = ((MockHttpServletResponse) mockPageContext.getResponse()).getContentAsString();

    assertEquals(&quot;Tag should return 'SKIP_BODY'&quot;, TagSupport.SKIP_BODY, tagReturnValue);
    assertEquals(&quot;Output should be 'Hello, Jeremy Anderson'&quot;, expectedOutput, output);

    verifyAllMocks();
}</pre><br />
Now when you run this code, you&#8217;ll get an error from EasyMock complaining about methods that were expected to be called, but weren&#8217;t.  So lets fix that now.  Modify the doStartTagInternal() method to look like the following.<br />
<pre class="brush: java;">

protected int doStartTagInternal() throws Exception {
        // Get the Spring Context from the RequestContext
        WebApplicationContext context = getRequestContext().getWebApplicationContext();

        // Get the service we want to call from the Spring Context
        someService = (SomeServiceInterface) context.getBean(&quot;someService&quot;);

        String fullName = someService.getFullName(userName);
        pageContext.getOut().print(&quot;Hello, &quot; + fullName);

        return SKIP_BODY;
    }

</pre><br />
Congratulations, you&#8217;ve now implemented a JSP Custom Tag using &#8220;Test First&#8221;.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codeadept.wordpress.com/26/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codeadept.wordpress.com/26/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeadept.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeadept.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeadept.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeadept.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeadept.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeadept.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeadept.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeadept.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeadept.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeadept.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeadept.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeadept.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeadept.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeadept.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.code-adept.com&amp;blog=2511053&amp;post=26&amp;subd=codeadept&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.code-adept.com/2008/01/25/unit-testing-jsp-custom-tags/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/611c688725819bb23742a714a9c33dfe?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jeremy</media:title>
		</media:content>
	</item>
		<item>
		<title>Continuous Integration with Flex</title>
		<link>http://blog.code-adept.com/2008/01/16/continuous-integration-with-flex/</link>
		<comments>http://blog.code-adept.com/2008/01/16/continuous-integration-with-flex/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 02:46:54 +0000</pubDate>
		<dc:creator>Jeremy Anderson</dc:creator>
				<category><![CDATA[RIA]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[continuous integration]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[flexunit]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://code-adept.com/2008/01/16/continuous-integration-with-flex/</guid>
		<description><![CDATA[Earlier today I had posed a question to a mailing list in the .NET community asking about Continuous Integration with Flex in the .NET world. After a couple of answers from people who obviously did not understand the question, because they just told me to google CruiseControl.NET, someone with some knowledge of TDD and Agile [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.code-adept.com&amp;blog=2511053&amp;post=14&amp;subd=codeadept&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Earlier today I had posed a question to a mailing list in the .NET community asking about Continuous Integration with Flex in the .NET world.  After a couple of answers from people who obviously did not understand the question, because they just told me to google CruiseControl.NET, someone with some knowledge of TDD and Agile practices stepped up and pointed out the obvious point I was trying to make.  <strong>There currently is no real good way to automate your FlexUnit tests in such a way that a CI server like CC.NET or HudsonCI would know whether or not all of the tests for your Actionscript classes passed or failed.</strong></p>
<p><span style="text-decoration:line-through;">So I&#8217;ve decided to start a Google Code project called agile-flex, where a couple of other developers and I will attempt to build some agile tools for the Flex framework, starting with a test runner that will help enable continuous integration for Java, .NET, or even just plain old Actionscript.  The runner will likely be based off an article I found from Aaron Spjut here<a href="http://www.aaronspjut.com/mind/index.php/2007/04/24/continuous-integration-with-flex-2-actionscript-3-flexunit-cruisecontrol-apollo-and-subversion-on-os-x/" target="_blank">.</a> In a nutshell we will create a test runner in Adobe AIR that will generate XML output similar to JUnit and NUnit for the CI server to be able to interpret.  This will also enable the generation of report artifacts using the JUnit Report tasks or even a custom XSLT if desired.  I&#8217;ll post more details as the project continues.</span></p>
<p>UPDATE&#8230; The Flex-Mojos project now fulfills this need, so I&#8217;ve deleted the Google Code Project that we started for this.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codeadept.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codeadept.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codeadept.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codeadept.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codeadept.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codeadept.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codeadept.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codeadept.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codeadept.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codeadept.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codeadept.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codeadept.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codeadept.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codeadept.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codeadept.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codeadept.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.code-adept.com&amp;blog=2511053&amp;post=14&amp;subd=codeadept&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.code-adept.com/2008/01/16/continuous-integration-with-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/611c688725819bb23742a714a9c33dfe?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jeremy</media:title>
		</media:content>
	</item>
	</channel>
</rss>
