<?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/"
	>

<channel>
	<title>Rod Coffin's Weblog</title>
	<atom:link href="http://blog.rodcoffin.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.rodcoffin.com</link>
	<description>Adventures in software development</description>
	<pubDate>Tue, 01 Sep 2009 01:23:51 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Infinitest and Scala</title>
		<link>http://blog.rodcoffin.com/?p=173</link>
		<comments>http://blog.rodcoffin.com/?p=173#comments</comments>
		<pubDate>Tue, 01 Sep 2009 01:21:32 +0000</pubDate>
		<dc:creator>rcoffin</dc:creator>
		
		<category><![CDATA[Agile]]></category>

		<category><![CDATA[IntelliJ IDEA]]></category>

		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.rodcoffin.com/?p=173</guid>
		<description><![CDATA[While at the agile 2009 conference last week Ben Rady and I sat down to figure out what we would need to do to get Infinitest working with Scala.  To our delight it worked right out of the box!  This is both a testament to the power of JVM based languages and the [...]]]></description>
			<content:encoded><![CDATA[<p>While at the agile 2009 conference last week <a href='http://feedbackjunkies.com/'>Ben Rady</a> and I sat down to figure out what we would need to do to get Infinitest working with Scala.  To our delight it worked right out of the box!  This is both a testament to the power of JVM based languages and the flexibility of <a href='http://improvingworks.com/?p=products'>Infinitest</a>.  <a href='http://bit.ly/4ryReJ'>Here</a> is a quick screen cast I put together to show just how easy it is to use Infinitest with Scala.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rodcoffin.com/?feed=rss2&amp;p=173</wfw:commentRss>
		</item>
		<item>
		<title>SCM Green Hooks</title>
		<link>http://blog.rodcoffin.com/?p=171</link>
		<comments>http://blog.rodcoffin.com/?p=171#comments</comments>
		<pubDate>Tue, 04 Aug 2009 02:19:04 +0000</pubDate>
		<dc:creator>rcoffin</dc:creator>
		
		<category><![CDATA[Agile]]></category>

		<category><![CDATA[IntelliJ IDEA]]></category>

		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.rodcoffin.com/?p=171</guid>
		<description><![CDATA[Today Improving Works released version 5.0.51 of Infinitest for IntelliJ.  This version includes IDE integrated support for SCM Green Hooks.  A green hook is an Infinitest term for an action which is taken when your tests are run and all of them are passing (green).  This SCM green hook will optionally perform [...]]]></description>
			<content:encoded><![CDATA[<p>Today <a href='http://improvingworks.com/'>Improving Works</a> released version 5.0.51 of <a href='http://infinitest.org'>Infinitest</a> for IntelliJ.  This version includes IDE integrated support for SCM Green Hooks.  A green hook is an Infinitest term for an action which is taken when your tests are run and all of them are passing (green).  This SCM green hook will optionally perform an update from whatever source code repositories you have configured for your project when the passing state is reached.  With this hook running you will not only be continuously testing your local copy of the project but will be continuously integrating and testing against the very latest state of your source code repository.  Green?  Go ahead and commit!</p>
<p>The screencast below explains this new feature and shows how to quickly get going with it.</p>
<p><span id="more-171"></span><br />
<object width="780" height="616"><param name="movie" value="http://content.screencast.com/users/rcoffin/folders/Default/media/dd3ce2df-97ae-4011-8891-c2bfd818cbcf/bootstrap.swf"></param><param name="quality" value="high"></param><param name="bgcolor" value="#FFFFFF"></param><param name="flashVars" value="thumb=http://content.screencast.com/users/rcoffin/folders/Default/media/dd3ce2df-97ae-4011-8891-c2bfd818cbcf/FirstFrame.jpg&#038;containerwidth=780&#038;containerheight=616&#038;content=http://content.screencast.com/users/rcoffin/folders/Default/media/dd3ce2df-97ae-4011-8891-c2bfd818cbcf/SCM%20Green%20Hook.swf"></param><param name="allowFullScreen" value="true"></param><param name="scale" value="showall"></param><param name="allowScriptAccess" value="always"></param><param name="base" value="http://content.screencast.com/users/rcoffin/folders/Default/media/dd3ce2df-97ae-4011-8891-c2bfd818cbcf/"></param>  <embed src="http://content.screencast.com/users/rcoffin/folders/Default/media/dd3ce2df-97ae-4011-8891-c2bfd818cbcf/bootstrap.swf" quality="high" bgcolor="#FFFFFF" width="780" height="616" type="application/x-shockwave-flash" allowScriptAccess="always" flashVars="thumb=http://content.screencast.com/users/rcoffin/folders/Default/media/dd3ce2df-97ae-4011-8891-c2bfd818cbcf/FirstFrame.jpg&#038;containerwidth=780&#038;containerheight=616&#038;content=http://content.screencast.com/users/rcoffin/folders/Default/media/dd3ce2df-97ae-4011-8891-c2bfd818cbcf/SCM%20Green%20Hook.swf" allowFullScreen="true" base="http://content.screencast.com/users/rcoffin/folders/Default/media/dd3ce2df-97ae-4011-8891-c2bfd818cbcf/" scale="showall"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rodcoffin.com/?feed=rss2&amp;p=171</wfw:commentRss>
		</item>
		<item>
		<title>Infinitest 5.0.26 Released</title>
		<link>http://blog.rodcoffin.com/?p=168</link>
		<comments>http://blog.rodcoffin.com/?p=168#comments</comments>
		<pubDate>Sat, 09 May 2009 19:48:53 +0000</pubDate>
		<dc:creator>rcoffin</dc:creator>
		
		<category><![CDATA[Agile]]></category>

		<category><![CDATA[IntelliJ IDEA]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blog.rodcoffin.com/?p=168</guid>
		<description><![CDATA[Infinitest 5.0.26 has been released and is available for download from the IntelliJ repository.  New features include:

Support for Java 6
Rogue marker fixes
Improved marker support for errors that occur outside the project and in 3rd party libraries.
Resolved a class file parsing issue that occurred with some projects

]]></description>
			<content:encoded><![CDATA[<p>Infinitest 5.0.26 has been released and is available for download from the IntelliJ repository.  New features include:</p>
<ul>
<li>Support for Java 6</li>
<li>Rogue marker fixes</li>
<li>Improved marker support for errors that occur outside the project and in 3rd party libraries.</li>
<li>Resolved a class file parsing issue that occurred with some projects</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.rodcoffin.com/?feed=rss2&amp;p=168</wfw:commentRss>
		</item>
		<item>
		<title>Infinitest for IntelliJ 5.0.0 Released</title>
		<link>http://blog.rodcoffin.com/?p=159</link>
		<comments>http://blog.rodcoffin.com/?p=159#comments</comments>
		<pubDate>Thu, 02 Apr 2009 19:01:14 +0000</pubDate>
		<dc:creator>rcoffin</dc:creator>
		
		<category><![CDATA[Agile]]></category>

		<category><![CDATA[IntelliJ IDEA]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blog.rodcoffin.com/?p=159</guid>
		<description><![CDATA[Today the Infinitest team is pleased to announce the release of Infinitest for IntelliJ version 5.0.0.  This new version includes two main features: gutter markers and a log tab.  The updated plugin is available for download from the plugin manager within IntelliJ.  Also, please check out our new and improved home page [...]]]></description>
			<content:encoded><![CDATA[<p>Today the Infinitest team is pleased to announce the release of Infinitest for IntelliJ version 5.0.0.  This new version includes two main features: gutter markers and a log tab.  The updated plugin is available for download from the plugin manager within IntelliJ.  Also, please check out our new and improved home page at <a href="http://www.infinitest.org">http://www.infinitest.org</a>.</p>
<p><span id="more-159"></span><br />
Gutter markers provide information on test failures within your code documents themselves.  For example, assertion failures within your unit tests are annotated like this:</p>
<p><img src="http://blog.rodcoffin.com/wp-content/uploads/2009/04/assertion-failure.png" alt="" width="562" height="346" /></p>
<p>And runtime exceptions are annotated at the point at which the exception was thrown, like this:</p>
<p><img src="http://blog.rodcoffin.com/wp-content/uploads/2009/04/exception.png" alt="" width="565" height="359" /></p>
<p>This new version also contains an additional tab which allows logging messages to be viewed:</p>
<p><img src="http://blog.rodcoffin.com/wp-content/uploads/2009/04/logging.png" alt="" width="571" height="110" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rodcoffin.com/?feed=rss2&amp;p=159</wfw:commentRss>
		</item>
		<item>
		<title>FacesTester 0.1 Released</title>
		<link>http://blog.rodcoffin.com/?p=154</link>
		<comments>http://blog.rodcoffin.com/?p=154#comments</comments>
		<pubDate>Thu, 02 Apr 2009 14:28:27 +0000</pubDate>
		<dc:creator>rcoffin</dc:creator>
		
		<category><![CDATA[Agile]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blog.rodcoffin.com/?p=154</guid>
		<description><![CDATA[Yesterday Jason Lee and I released our first version (0.1) of FacesTester, a test framework for JavaServer Faces applications.  Jason has a great write-up on features included in this release on his blog at http://blogs.steeplesoft.com/facestester-01-released/ that I won&#8217;t repeat here.  But I encourage you to give this tool a test drive if you&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday <a href='http://blogs.steeplesoft.com/'>Jason Lee</a> and I released our first version (0.1) of <a href='http://kenai.com/projects/facestester/'>FacesTester</a>, a test framework for JavaServer Faces applications.  Jason has a great write-up on features included in this release on his blog at <a href='http://blogs.steeplesoft.com/'>http://blogs.steeplesoft.com/facestester-01-released/</a> that I won&#8217;t repeat here.  But I encourage you to give this tool a test drive if you&#8217;re a JSF developer looking for a solution to test driving your JSF code.  The project is being hosted at <a href='http://kenai.com/projects/facestester/'>Kenai</a> where you can access our mailing issues, issue tracker, etc.  We would appreciate any feedback you have.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rodcoffin.com/?feed=rss2&amp;p=154</wfw:commentRss>
		</item>
		<item>
		<title>Introducing Faces Tester</title>
		<link>http://blog.rodcoffin.com/?p=137</link>
		<comments>http://blog.rodcoffin.com/?p=137#comments</comments>
		<pubDate>Sun, 29 Mar 2009 13:05:54 +0000</pubDate>
		<dc:creator>rcoffin</dc:creator>
		
		<category><![CDATA[Agile]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blog.rodcoffin.com/?p=137</guid>
		<description><![CDATA[For the last month or so I have been working on a test framework for JavaServer Faces applications with my friend Jason Lee.  The goal of this framework, named FacesTester, is to enable the test driving of JSF applications.  Earlier Jason announced FacesTester and today I&#8217;d like to illustrate one very simple example [...]]]></description>
			<content:encoded><![CDATA[<p>For the last month or so I have been working on a test framework for JavaServer Faces applications with my friend <a href='http://blogs.steeplesoft.com'>Jason Lee</a>.  The goal of this framework, named <a href='http://kenai.com/projects/facestester'>FacesTester</a>, is to enable the test driving of JSF applications.  Earlier Jason <a href='http://blogs.steeplesoft.com/announcing-facestester/'>announced</a> FacesTester and today I&#8217;d like to illustrate one very simple example of how FacesTester can be used to specify a simple web interaction in a test driven manner.</p>
<p><span id="more-137"></span><br />
Following in the well trodden path of others let&#8217;s start by making a quick login page.  Using FacesTester I can write a JUnit test like the following that describes how I want this simple page to work:</p>
<pre class="brush: java;">
public class WhenClickingTheLoginButton {
    @Test
    public void shouldDisplayGreetingToUserNamedInUsernameField() {
        FacesTester tester = new FacesTester();
        FacesPage page = tester.requestPage(&quot;/login.xhtml&quot;);

        FacesForm form = page.getFormById(&quot;form&quot;);
        form.setValue(&quot;username&quot;, &quot;Rod&quot;);
        form.submit(&quot;login&quot;);

        assertThat(page.getComponentWithId(&quot;greeting&quot;).getValueAsString(), is(&quot;Hello, Rod!&quot;));
    }
}
</pre>
<p>As you can see this test specifies that if a user types in their username and clicks the login button then they should receive a friendly greeting from the system.  This test fails when run since we haven&#8217;t written any production code yet.  The message we get is:</p>
<pre>com.steeplesoft.jsf.facestester.FacesTesterException: The page /login.xhtml was not found.</pre>
<p>So let&#8217;s create a simple HTML to pass the previous specification.  You&#8217;ll notice that in this example we&#8217;re using facelets for the view technology:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
        &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
      xmlns:ui=&quot;http://java.sun.com/jsf/facelets&quot;
      xmlns:h=&quot;http://java.sun.com/jsf/html&quot;&gt;
&lt;body&gt;&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Running the test now produces the following message:</p>
<pre>java.lang.AssertionError: HtmlForm 'form' does not exist on page.</pre>
<p>Ok, so now we need to place our components on the page.  I&#8217;m going to add all three now to save space, but I would normally do this one at a time in quick TDD loops:</p>
<pre class="brush: xml;">
&lt;body&gt;
&lt;h:form id=&quot;form&quot;&gt;
    &lt;h:inputText id=&quot;username&quot;/&gt;
    &lt;h:commandButton id=&quot;login&quot;/&gt;
&lt;/h:form&gt;
&lt;h:outputText id=&quot;greeting&quot;/&gt;
&lt;/body&gt;
</pre>
<p>Re-run our test and now we get the message:</p>
<pre>
	java.lang.AssertionError:
	Expected: is "Hello, Rod!"
	     got: null
</pre>
<p>So now, to actually implement some logical behavior to happen when the login button is pressed.  First, let&#8217;s declare a managed bean in the faces-config.xml descriptor:</p>
<pre class="brush: xml;">
&lt;managed-bean&gt;
    &lt;managed-bean-name&gt;LoginPage&lt;/managed-bean-name&gt;
    &lt;managed-bean-class&gt;com.steeplesoft.jsf.sample.LoginPage&lt;/managed-bean-class&gt;
    &lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt;
&lt;/managed-bean&gt;
</pre>
<p>And of course, actually create the bean.</p>
<pre class="brush: java;">
public class LoginPage {
    private String name;
    private String greeting;

    public String login() {
        greeting = &quot;Hello, &quot; + name + &quot;!&quot;;

        return null;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public String getGreeting() {
        return greeting;
    }
}
</pre>
<p>Bind it to the actual components on the page:</p>
<pre class="brush: xml;">
&lt;body&gt;
&lt;h:form id=&quot;form&quot;&gt;
    &lt;h:inputText id=&quot;username&quot; value=&quot;#{LoginPage.name}&quot;/&gt;
    &lt;h:commandButton id=&quot;login&quot; action=&quot;#{LoginPage.login}&quot;/&gt;
&lt;/h:form&gt;
&lt;h:outputText id=&quot;greeting&quot; value=&quot;#{LoginPage.greeting}&quot;/&gt;
&lt;/body&gt;
</pre>
<p>Re-running our test shows passes, and running the application shows that our quick login page is now working correctly!  We have been able to test drive the interaction of these user interface components in a simple and meaningful way.</p>
<p><img src='http://blog.rodcoffin.com/wp-content/uploads/2009/03/hellorod.png'/></p>
<p>We are planning on releasing 0.1, or first public release, sometime soon so keep an eye out here or at Jason&#8217;s site.  Also, we are adding features in a test-driven manner meaning that we are using test scenarios like the simple one above to guide the functionality we&#8217;re building into FacesTester.  Like to see some particular features in FacesTester?  Just sketch out a test similar to the one above and send it to us.  You&#8217;re input will help us out tremendously.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rodcoffin.com/?feed=rss2&amp;p=137</wfw:commentRss>
		</item>
		<item>
		<title>Presenting at SD West 2009</title>
		<link>http://blog.rodcoffin.com/?p=132</link>
		<comments>http://blog.rodcoffin.com/?p=132#comments</comments>
		<pubDate>Thu, 05 Mar 2009 16:05:29 +0000</pubDate>
		<dc:creator>rcoffin</dc:creator>
		
		<category><![CDATA[Self Promotion]]></category>

		<guid isPermaLink="false">http://blog.rodcoffin.com/?p=132</guid>
		<description><![CDATA[Next week (March, 9-14) I will be presenting at SD West 2009.  SD West is always a great conference and I highly recommend making the trip out to Santa Clara one year and checking it out.  If you are fortunate enough to be making the trip this year I invite you to come [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.rodcoffin.com/wp-content/uploads/2009/03/sdwest2009.gif" alt="sdwest2009" height="90" width="120" align="left" hspace='15' vspace='5'>Next week (March, 9-14) I will be presenting at <a href='http://www.sdexpo.com/'>SD West 2009</a>.  SD West is always a great conference and I highly recommend making the trip out to Santa Clara one year and checking it out.  If you are fortunate enough to be making the trip this year I invite you to come to any of the three sessions I am giving.</p>
<p><br/><br />
<br/></p>
<p><span id="more-132"></span><br />
<strong>Set your User Stories Free with Groovy&#8217;s easyb</strong></p>
<p><em>Co-presenting with Andrew Glover</em></p>
<p>Leveraging user stories during application development enables intelligent handling of customer requirements without having to create deeply formalized requirement documents. What&#8217;s more, user stories are an excellent mechanism for availing the expertise of a customer in authoring an appropriate acceptance procedure, which logically ensures the goals of the user story have been fulfilled by development. By employing user stories, teams are able to respond faster to rapidly changing real-world requirements. Yet, automating story testing with most current tools, such as FIT and GreenPepper, for example, can be cumbersome to the point that these tools detract from the conversations (between stake-holders and development) that are a core aspect of user stories. With the emergence of dynamic languages that easily incorporate the creation of domain specific languages, new tools are materializing that more easily leverage users. One such tool is easyb, which is an open source Java based framework that provides a syntax for defining stories and scenarios in a concise manner that ends up staying out of the way such that development teams can more effectively collaborate with stake-holders while having a powerful framework for binding user stories to the system under test. These stories then more appropriately serve as a mechanism for validating a user conversation against the system over time. </p>
<p><strong>Scaling Everest - Testing a Web Application</strong></p>
<p>Testing web applications is notoriously difficult. Historically, this has been because of the interactive nature of web applications, the distribution inherent in the browser-server model, browser diversity, and framework specific issues. Because of these challenges, developing good tests for web applications is often expensive and those tests are often fragile and require ongoing effort to keep relevant. This session will demonstrate various tools, techniques, and strategies for creating cost-effective and maintainable tests for web applications while putting these to work in testing a live application. These tests will progressively scale higher up the application stack as we explore the trade-offs associated with testing at various levels, including: executing tests at the highest level of the application just inside the container boundary; executing test at the web framework level; executing tests as though you were a browser; executing tests through a real browser. Attendees will come away with a deeper understanding of tools and techniques which can be used to develop their own strategy for effectively conquering the web testing mountain.</p>
<p><strong>Continuous Testing: TDD Turned Up To 12</strong></p>
<p>Continuous Testing (CT) is a developer practice that involves automatically running tests after every change, even so much as a single statement. It gives you instant feedback about the semantic correctness of your code, just as modern IDE’s give you instant feedback about syntax errors. CT has a profound impact on the way we use TDD. This session will cover the history, theory, practice, and daily application of CT to real-world projects. First, we will cover the history and basics of Continuous Testing, discuss it’s application on different platforms, and the presenter&#8217;s ongoing experiences with CT on several systems. Then we&#8217;ll demo the practice using various languages and some open source continuous testing tools. Finally, we’ll wrap up with a discussion of where this practice might be headed.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rodcoffin.com/?feed=rss2&amp;p=132</wfw:commentRss>
		</item>
		<item>
		<title>Raising the Bar with Continuous Testing</title>
		<link>http://blog.rodcoffin.com/?p=130</link>
		<comments>http://blog.rodcoffin.com/?p=130#comments</comments>
		<pubDate>Wed, 11 Feb 2009 19:25:13 +0000</pubDate>
		<dc:creator>rcoffin</dc:creator>
		
		<category><![CDATA[Agile]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blog.rodcoffin.com/?p=130</guid>
		<description><![CDATA[Earlier this week the Agile Journal published my article on continuous testing.  Please check it out, I would love to hear any feedback you have on the article, CT, or Infinitest.
]]></description>
			<content:encoded><![CDATA[<p>Earlier this week the Agile Journal published <a href="http://www.agilejournal.com/component/content/article/1221--raising-the-bar-with-continuous-testing">my article</a> on continuous testing.  Please check it out, I would love to hear any feedback you have on the article, CT, or Infinitest.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rodcoffin.com/?feed=rss2&amp;p=130</wfw:commentRss>
		</item>
		<item>
		<title>Hello, Dave</title>
		<link>http://blog.rodcoffin.com/?p=119</link>
		<comments>http://blog.rodcoffin.com/?p=119#comments</comments>
		<pubDate>Mon, 19 Jan 2009 19:47:23 +0000</pubDate>
		<dc:creator>rcoffin</dc:creator>
		
		<category><![CDATA[Agile]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blog.rodcoffin.com/?p=119</guid>
		<description><![CDATA[There are quite a few good tools available for developers who are interested in writing more expressive tests.  Frequent readers of this blog will doubtless know that I am a big proponent of easyb which is a very effective groovy-based Behavior Driven Development (BDD) tool.  But what if your organization doesn&#8217;t support the [...]]]></description>
			<content:encoded><![CDATA[<p>There are quite a few good tools available for developers who are interested in writing more expressive tests.  Frequent readers of this blog will doubtless know that I am a big proponent of easyb which is a very effective groovy-based Behavior Driven Development (BDD) tool.  But what if your organization doesn&#8217;t support the use of Groovy or you are not fortunate enough to use the IntelliJ IDE (for which easyb has direct support for)?  Other popular tools in this vein include <a href='http://fit.c2.com/'>Fit</a>, <a href='http://fitnesse.org/'>Fitnesse</a>, <a href='http://www.greenpeppersoftware.com/en/'>GreenPepper</a>, <a href='http://rspec.info/'>RSpec</a>, and <a href='http://www.concordion.org/'>Concordian</a> among others.  These all share a desire to more expressively represent system behavior in an automated manner.  But like all tools, they have their own challenges as well.  They all introduce their own syntax for expressing behavior which can make writing specs more cumbersome.  And they all require special methods for running them introducing very real tooling issues.  In this brief post I will introduce how you can begin to write more expressive BDD-styled tests through JUnit, and how the JUnit-based BDD tool <a href='http://www.jdave.org/'>JDave</a> can help you find some of the expressiveness offered by the tools listed above without having to venture out beyond the ubiquitous JUnit platform.</p>
<p><span id="more-119"></span><br />
BDD is an extension to Test Driven Development (TDD) which re-orients the language of testing from the structure of your code (classes and tests) to the behaviors your system <strong>should</strong> exhibit.  Consider the following user story:</p>
<pre class="brush: java;">
As a bank customer
I want to be able to withdraw funds from my account
So that I can have ready access to cash
</pre>
<p>We can refine this specification by identifying some acceptance criteria:</p>
<pre class="brush: java;">
Given an account with a balance of $500
When a customer withdraws $100
Then the account should have a balance of $400
</pre>
<p>We could write a test for this behavior using traditional unit testing syntax as follows:</p>
<pre class="brush: java;">
public class AccountTest extends TestCase {
	public void testWithdraw() {
		Account account = new Account(500);
		account.withdraw(100);
		assertEquals(400, account.balance());
	}
}
</pre>
<p>With this approach the structure of test is coupled to the structure of our implementation class.  Specifically, the AccountTest class is related by naming convention to the Account class and the testWithdraw method is related to the withdraw method of Account.  A BDD approach would change the syntax of this tests to relate it to a system behavior rather then specific implementation component.  In BDD parlance this is referred to as a spec instead of a test and could look like the following:</p>
<pre class="brush: java;">
public class WhenWithdrawingMoney {
	@Test
	public void shouldDecreaseAccountBalance() {
		Account account = new Account(500);
		account.withdraw(100);
		assertThat(account.balance(), is(400));
	}
}
</pre>
<p>Reading the test class name and the method name together produces the phrase &#8220;When withdrawing money should decrease account balance.&#8221;  This is very descriptive of behavior that the spec is asserting the system should exhibit.</p>
<p><a href='http://www.jdave.org/'>JDave</a> is a JUnit-based BDD framework that expands the syntax available for use in writing BDD-styled specs such as should, must, not, where, contains, etc.  We can express the same test uses JDave as follows:</p>
<pre class="brush: java;">
@RunWith(JDaveRunner.class)
public class AccountSpecs extends Specification&lt;Account&gt; {
	public class WhenWithdrawingMoney {
		public void shouldDecreaseAccountBalance() {
			Account account = new Account(500);
			account.withdraw(100);
			specify(account.balance(), should.equal(400));
		}
	}
}
</pre>
<p>So there are a host of tools and techniques that enable one to write expressive tests with just Java and JUnit.  These are great ideas to keep in your developer toolkit.  But even with techniques such as these writing tests built upon plain Java doesn&#8217;t rival these same conciseness afforded to tools such as easyb which are free of the constraints of the Java language.  For example, consider this test written with JDave:</p>
<pre class="brush: java;">
	public class WhenWithdrawingMoney {
		public void shouldNotAllowWithdrawalOfNegativeAmount() {
			final Account account = new Account(500);
			specify(new Block() {
				public void run() throws Throwable {
					account.withdraw(-100);
				}
			}, must.raise(RuntimeException.class));
		}
	}
</pre>
<p>Because Java doesn&#8217;t offer support for closures this test is slightly obscured by three additional lines required to define an anonymous inner class.  Instead easyb this test could be expressed as:</p>
<pre class="brush: java;">
it &quot;should throw exception for negative withdraw amounts&quot;, {
  Account account = new Account(500);
  ensureThrows(RuntimeException) { account.withdraw(-100) }
}
</pre>
<p>In conclusion, if you would like to write more expressive, BDD-styled, specifications for your system and aren&#8217;t able to use more powerful tools for whatever reason, you can still go quite a towards accomplishing this goal with the Java language, and JUnit.  And tools such as JDave, and Hamcrest (which I didn&#8217;t cover here) can help make these tests yet more expressive while not deviating from the ubiquity of the JUnit platform.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rodcoffin.com/?feed=rss2&amp;p=119</wfw:commentRss>
		</item>
		<item>
		<title>Free Consulting!</title>
		<link>http://blog.rodcoffin.com/?p=117</link>
		<comments>http://blog.rodcoffin.com/?p=117#comments</comments>
		<pubDate>Tue, 13 Jan 2009 15:31:21 +0000</pubDate>
		<dc:creator>rcoffin</dc:creator>
		
		<category><![CDATA[Self Promotion]]></category>

		<guid isPermaLink="false">http://blog.rodcoffin.com/?p=117</guid>
		<description><![CDATA[Nowadays everyone is looking for better ways of doing more with less.  Companies are reducing staff, slashing budgets, and deferring major new investments while those remaining are left to shoulder the added burden created by these cuts.  I believe that in order for software development teams to successfully meet these challenges they need [...]]]></description>
			<content:encoded><![CDATA[<p>Nowadays everyone is looking for better ways of doing more with less.  Companies are reducing staff, slashing budgets, and deferring major new investments while those remaining are left to shoulder the added burden created by these cuts.  I believe that in order for software development teams to successfully meet these challenges they need to continue to find new and innovation ways of applying disciplined software development practices to their craft.  Project automation, continuous integration, unit testing, test/behavior driven development, and continuous testing are practices that should be a part of every software developer&#8217;s arsenal.</p>
<p>These are all topics that I&#8217;m passionate about sharing with others and for a very limited time I am offering free 2-4 hour consulting sessions to explore any of these areas with you and/or your company, no strings attached!  For companies in the DFW Metroplex I would be happy to come to you to run a brown-bag session, talk about any challenges you&#8217;re experiencing or questions you my have, or even pull up a chair and do a little bit of pair programming.  If you&#8217;re outside of DFW I would be happy to talk on the phone or run a web-based presentation for you.</p>
<p>What I hope to get out of this is simple: opportunities to talk with others about areas that I find interesting, to run through presentations I will be giving at industry events later in the year, and to forge new relationships with people and companies.  So if you&#8217;re interested in taking me up on this offer then please feel free to contact me by email at rod.coffin@improvingenterprises.com.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rodcoffin.com/?feed=rss2&amp;p=117</wfw:commentRss>
		</item>
	</channel>
</rss>
