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

<channel>
	<title>maxheapsize.com &#187; bdd</title>
	<atom:link href="http://maxheapsize.com/tag/bdd/feed/" rel="self" type="application/rss+xml" />
	<link>http://maxheapsize.com</link>
	<description>Oliver Wehrens on Programming and Agile</description>
	<lastBuildDate>Tue, 14 Jun 2011 20:41:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Behavior driven development with EasyB (and vs. TestNG)</title>
		<link>http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/</link>
		<comments>http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 21:42:53 +0000</pubDate>
		<dc:creator>Oliver Wehrens</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[easyb]]></category>
		<category><![CDATA[grovvy]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://maxheapsize.com/?p=12</guid>
		<description><![CDATA[I heard about BDD a couple of months ago and did not really pay attention. Just some weeks ago I thought that maybe I could improve our test and/or documentation. So I decided to give it a shot with the BDD implementation easyb. According to Wikipedia: Behavior Driven Development (or BDD) is an Agile software [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fmaxheapsize.com%2F2009%2F02%2F10%2Fbehavior-driven-development-with-easyb-and-vs-testng%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fmaxheapsize.com%2F2009%2F02%2F10%2Fbehavior-driven-development-with-easyb-and-vs-testng%2F&amp;source=owehrens&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I heard about BDD a couple of months ago and did not really pay attention. Just some weeks ago I thought that maybe I could improve our test and/or documentation. So I decided to give it a shot with the BDD implementation <a href="http://easyb.org">easyb</a>.</p>
<p>According to Wikipedia:</p>
<blockquote><p><strong>Behavior Driven Development</strong> (or <strong>BDD</strong>) is an <a title="Agile software development" href="http://en.wikipedia.org/wiki/Agile_software_development">Agile software development</a> technique that encourages collaboration between developers, QA and non-technical or business participants in a software project. It was originally conceived in 2003 by Dan North <sup id="cite_ref-origin_0-0" class="reference"><a href="http://en.wikipedia.org/wiki/Behavior_Driven_Development#cite_note-origin-0"></a></sup>as a response to <a class="mw-redirect" title="Test Driven Development" href="http://en.wikipedia.org/wiki/Test_Driven_Development">Test Driven Development</a>, and has evolved over the last few years.</p></blockquote>
<p>So I took the chance to sketch out a little example and to test it against readability.</p>
<p>This is the class which I would to test with BDD and classic TestNG.</p>
<pre class="brush: java; title: ;">
package net.wehrens.easyb;

import java.util.ArrayList;
import java.util.List;

public class Car {
    private boolean engineInstalled;
    private int doors;
    private List&amp;lt;Wheel&amp;gt; wheels = new ArrayList&amp;lt;Wheel&amp;gt;();

    public void addDoor() { doors++; }
    public void addEngine() { engineInstalled = true; }
    public boolean isEngineInstalled() { return engineInstalled; }
    public int getDoors() { return doors; }
    public void addWheel(Wheel p_wheel) { wheels.add(p_wheel); }
    public List&amp;lt;Wheel&amp;gt; getWheels() { return wheels; }
}
</pre>
<p>The testcode in easyb looks very descriptive (and even my Product Owner can understand what&#8217;s happening). It uses Groovy to create it&#8217;s own DSL for writing tests. Even if I don&#8217;t explain any more you have a good chance to understand it at the first read.</p>
<pre class="brush: java; title: ;">
import net.wehrens.easyb.Car
import net.wehrens.easyb.Wheel

scenario &quot;make a new car with one door&quot;, {
  given &quot;a new car&quot;, {
    car = new Car()
  }

  when &quot;a door is added&quot;, {
    car.addDoor()
  }

  then &quot;car should have one door&quot;, {
    car.doors.shouldBe 1
  }
}

scenario &quot;make a car with an engine&quot;, {

  given &quot;a new car&quot;, {
    car = new Car()
  }

  when &quot;an engine is added&quot;, {
    car.addEngine()
  }

  then &quot;the car should have an engine&quot;, {
    ensure(car.engineInstalled)
  }
}
</pre>
<p>The TestNG version of this test looks a little bit tighter but not as easy to understand for non programmers.</p>
<pre class="brush: java; title: ;">
package net.wehrens.easyb;

import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class CarTest {
    private Car _car;

    @BeforeMethod
    public void setUp() {
        _car = new Car();
    }

    @Test
    public void testAddEngine() {
        _car.addEngine();
        Assert.assertTrue(_car.isEngineInstalled());
    }

    @Test
    public void testAddDoor() {
        _car.addDoor();
        Assert.assertEquals(_car.getDoors(), 1);
    }
}
</pre>
<p>The big advantage I see here is that non technical people could be able to design test, how the code should behave, what the results should be. This is an often underestimated problem when communicating with the requirements engineers. Just write the BDD tests and the developers make sure they will turn green. The neat thing is that easyb has maven 2 integration and an IntelliJ Idea plugin. This makes working with it a breeze.</p>
<p>Sure sounds easy, but I by myself did not had a chance yet to try that out in a more complex environment&#8230;maybe stuff for a later post.</p>
<div class="google_plusone_widget"><g:plusone 
      count="true" href="http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/" size="medium"></g:plusone></div><!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/&amp;title=Behavior+driven+development+with+EasyB+%28and+vs.+TestNG%29" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/&amp;title=Behavior+driven+development+with+EasyB+%28and+vs.+TestNG%29" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Behavior+driven+development+with+EasyB+%28and+vs.+TestNG%29&amp;url=http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/&amp;title=Behavior+driven+development+with+EasyB+%28and+vs.+TestNG%29" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/&amp;title=Behavior+driven+development+with+EasyB+%28and+vs.+TestNG%29" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/&amp;bm_description=Behavior+driven+development+with+EasyB+%28and+vs.+TestNG%29" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/&amp;title=Behavior+driven+development+with+EasyB+%28and+vs.+TestNG%29" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/&amp;title=Behavior+driven+development+with+EasyB+%28and+vs.+TestNG%29" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.sphere.com/sphereit/http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/" rel="nofollow" title="Add to&nbsp;SphereIt"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/sphereit.png" title="Add to&nbsp;SphereIt" alt="Add to&nbsp;SphereIt" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/&amp;title=Behavior+driven+development+with+EasyB+%28and+vs.+TestNG%29" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Behavior+driven+development+with+EasyB+%28and+vs.+TestNG%29+@+http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://maxheapsize.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://maxheapsize.com/2009/02/10/behavior-driven-development-with-easyb-and-vs-testng/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

