<?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>Liz Keogh&#039;s blog &#187; jbehave</title>
	<atom:link href="http://lizkeogh.com/category/jbehave/feed/" rel="self" type="application/rss+xml" />
	<link>http://lizkeogh.com</link>
	<description>Software, Training, Coaching, Writing</description>
	<lastBuildDate>Thu, 17 May 2012 18:05:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Pulling Power and Kanban experiences</title>
		<link>http://lizkeogh.com/2009/05/29/pulling-power-and-kanban-experiences/</link>
		<comments>http://lizkeogh.com/2009/05/29/pulling-power-and-kanban-experiences/#comments</comments>
		<pubDate>Fri, 29 May 2009 10:07:18 +0000</pubDate>
		<dc:creator>liz</dc:creator>
				<category><![CDATA[bdd]]></category>
		<category><![CDATA[jbehave]]></category>
		<category><![CDATA[kanban]]></category>
		<category><![CDATA[lean]]></category>
		<category><![CDATA[stories]]></category>
		<category><![CDATA[writing]]></category>

		<guid isPermaLink="false">http://lizkeogh.com/?p=414</guid>
		<description><![CDATA[My first ever article, &#8220;Pulling Power: a new Software Lifespan&#8221; is up on InfoQ. BDD, Feature Injection, Lean and Kanban playing nice together!
Big thanks to Dan North, Chris Matts, David Anderson, Amr Elssamadisy and the amalgam of developers who make up &#8220;Jerry&#8221;; also to the Thoughtworkers who reviewed my article and gave me advice, and [...]]]></description>
			<content:encoded><![CDATA[<p>My first ever article, <a href="http://www.infoq.com/news/2009/05/pulling-power">&#8220;Pulling Power: a new Software Lifespan&#8221;</a> is up on <a href="http://www.infoq.com">InfoQ</a>. BDD, Feature Injection, Lean and Kanban playing nice together!</p>
<p>Big thanks to Dan North, Chris Matts, David Anderson, Amr Elssamadisy and the amalgam of developers who make up &#8220;Jerry&#8221;; also to the Thoughtworkers who reviewed my article and gave me advice, and the Kanbanjins like Eric Willeke who patiently talked me through Lean and Kanban. Several times. Anything I still haven&#8217;t understood is my error, not theirs.</p>
<p>I wish I could have put in everything I&#8217;ve learnt about Kanban, which is far larger than this article allows. It strikes me as a lovely, simple, high-discipline, least-wasteful way to deliver software, and it matches my feeling that you should fit your process to reality, not reality to your process.</p>
<p>My experiments with Kanban boards so far have been highly successful. Now I want to know about the problems, too. Have you tried Kanban? What happened? Did you try to introduce it? Did that work out? If not, why not? Did you think about introducing it, but decide not to? Tell me your stories!</p>
]]></content:encoded>
			<wfw:commentRss>http://lizkeogh.com/2009/05/29/pulling-power-and-kanban-experiences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Given / When / Then granularity</title>
		<link>http://lizkeogh.com/2009/04/16/given-when-then-granularity/</link>
		<comments>http://lizkeogh.com/2009/04/16/given-when-then-granularity/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 17:24:18 +0000</pubDate>
		<dc:creator>liz</dc:creator>
				<category><![CDATA[bdd]]></category>
		<category><![CDATA[jbehave]]></category>
		<category><![CDATA[stories]]></category>

		<guid isPermaLink="false">http://lizkeogh.com/?p=405</guid>
		<description><![CDATA[When we first wrote JBehave 1.0 we quickly recognised that there was power in the scenarios; in the conversations that they could help to drive, and in the reusability of the steps.
I loved the ease with which you could combine smaller steps to make bigger ones, use scenarios as the contexts of further scenarios, and [...]]]></description>
			<content:encoded><![CDATA[<p>When we first wrote <a href="http://jbehave.org">JBehave</a> 1.0 we quickly recognised that there was power in the scenarios; in the conversations that they could help to drive, and in the reusability of the steps.</p>
<p>I loved the ease with which you could combine smaller steps to make bigger ones, use scenarios as the contexts of further scenarios, and take the necessarily procedural automated tests and turn them into sets of reusable objects.</p>
<p>Now BDD is more widely used, and people out there are using JBehave 2 and RSpec, and I hear complaints. Amongst them, this is one of the more common:</p>
<p>&#8220;Every time I change this screen, I have to go through fifteen files and add another step.&#8221;</p>
<p>Since JBehave uses plain text scenarios you can&#8217;t rely on the common refactoring tools, and that can make it a bit more painful than just messing with code. So, I thought I&#8217;d have a go at explaining how I avoid this issue; by sharing some of the ways in which I divide or combine contexts, events and outcomes into reusable components that help me avoid duplication in my scenarios.</p>
<h3>Given a context</h3>
<p>A context is a state which was set up by irrelevant forces, and which is used within the scenario to alter the outcome resulting from the events.</p>
<p>If the manner or time in which the context was set up matters, then that, too, is part of the context; unless it&#8217;s part of the behaviour you&#8217;re looking for, in which case it&#8217;s an event. The only reason for separating the contexts in which a scenario occurs from the events which are performed in the scenario is because it doesn&#8217;t matter how they were created. This means that <a href="http://lizkeogh.com/2008/11/18/four-ways-of-handling-givens/">Givens have more flexibility</a> in implementation than Whens.</p>
<p><strong>A context should matter.</strong> If you can remove the context from the scenario without changing the outcomes, it isn&#8217;t part of the Givens.</p>
<p><strong>A context should be independent of other contexts.</strong> So, I prefer <em>Given a wet newspaper</em> to <em>Given a newspaper / Given that the newspaper is wet</em>. The first is less likely to require refactoring than the second.</p>
<p><strong>A context should create an abandonable artifact.</strong> By this I mean that the forces which created the artifact &#8211; data in the database, files on the disk, a particular page at a given URL &#8211; can safely forget about the context they&#8217;ve created. <em>Given an article about Iraq</em> is a good context. <em>Given I am logged in</em> is not so good, even though we frequently use it as an example. Sorry. If it helps, it&#8217;s a step that rarely needs maintenance. <em>Given we&#8217;ve filled in the comment box and are ready to submit it</em> is likely to cause issues, because of all the other tiny steps that you have to use to get there.</p>
<h3>When an event happens</h3>
<p>An event exercises the feature whose behaviour you&#8217;re interested in when describing or running the scenario.</p>
<p>If you don&#8217;t care whether it works as long as it leaves things in a clean state, it&#8217;s a context. If you don&#8217;t actually need to do anything to cause an outcome &#8211; you&#8217;re simply checking that given some state, some other state is also present &#8211; you don&#8217;t need to write an event; just skip straight from Given to Then.</p>
<p><strong>An event should create a valuable outcome.</strong>The granularity of the ideal event is very similar to that of the ideal context. As a user, I don&#8217;t want to go to the screen with the book, click the purchase button, navigate to the basket, enter the credit card number and click &#8220;submit&#8221;. I just want to buy a book. By specifying the steps which a user purchases a book inside the granularity of this larger step, we capture the value of that step. Since people rarely do things that they (or their sponsor, paymaster, loved one, etc.) don&#8217;t find valuable, this can usually be reused as one large step.</p>
<p><strong>An event may be dependent on context or on another event.</strong> So, when I buy a book, and when I cancel my order within 15 days, then I should not be charged for the book.</p>
<p><strong>An event should cause or contribute to an outcome.</strong> The outcome is something measurable. It could be that the outcome you&#8217;re looking for is an absence of something, for instance if a user&#8217;s preferences have been changed, and you no longer want to see all those Facebook groups. If it doesn&#8217;t cause an outcome, it&#8217;s a fairly irrelevant event.</p>
<h3>Then an outcome occurs</h3>
<p>An outcome describes the benefit that your system or application provides when the events are performed in the given context.</p>
<p><strong>An outcome should have teeth.</strong> If a particular error message doesn&#8217;t have the exact wording expected, the world will not come to an end. If my credit card gets billed for the books but I don&#8217;t get them when I expect, it might.</p>
<p><strong>An Outcome should be Specific, Measurable, Achievable, Relevant and Timeboxed.</strong> Ask a QA if you don&#8217;t know what this means. QAs are wise and can break anything.</p>
<p><strong>An Outcome should represent the valuable purpose of the events.</strong> Instead of checking that a series of menus exist when you navigate to a particular screen, write a scenario that uses those menus and check that the benefits they provide are accessible through them.</p>
<h3>Stories and regression tests</h3>
<p>It can take quite a while to run scenarios. I sometimes like to <a href="http://lizkeogh.com/2007/10/25/bdd-regression-testing-and-some-feature-requests/">turn mine into regression tests</a> by combining them. I like to add contexts, events and outcomes to existing scenarios to better describe the benefits of using any particular feature in any particular context. This may mean that scenarios are related to more than one story. This will help keep them maintainable, and isn&#8217;t a bad thing.</p>
<p>I have never found the need to add a context to a scenario half-way through that scenario, even if it&#8217;s been created from several others.</p>
<p>I do frequently use one scenario as the context for other scenarios.</p>
<h3>Unteaching the business</h3>
<p>Sometimes, we accidentally train our business to talk to us about the solutions they&#8217;d like, occasionally in the language of software development. In that case, they&#8217;ll quite happily discuss the particular steps they need to take in the GUI to achieve the desired outcome, and may even have an idea of the underlying database tables and discuss what ought to be in those tables after the events.</p>
<p>If this happens, try to draw the conversation back to how the data will be used; why it&#8217;s valuable to produce that artifact in the first place. You never know; you may find you need to do less work than you thought you did.</p>
]]></content:encoded>
			<wfw:commentRss>http://lizkeogh.com/2009/04/16/given-when-then-granularity/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JBehave 2.0 is released!</title>
		<link>http://lizkeogh.com/2008/09/03/jbehave-20-is-released/</link>
		<comments>http://lizkeogh.com/2008/09/03/jbehave-20-is-released/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 16:50:11 +0000</pubDate>
		<dc:creator>liz</dc:creator>
				<category><![CDATA[jbehave]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[JBehave2]]></category>

		<guid isPermaLink="false">http://lizkeogh.com/?p=376</guid>
		<description><![CDATA[We discovered some time ago that JBehave 1.0 wasn&#8217;t being used. When we found out that it took over an hour to write the scenarios for the Game of Life, we realised why.
Our goal with JBehave 2 was to make the process of collaboration, drawing up scenarios and getting started easy and simple. Feedback from [...]]]></description>
			<content:encoded><![CDATA[<p>We discovered some time ago that JBehave 1.0 wasn&#8217;t being used. When we found out that it took over an hour to write the scenarios for the Game of Life, we realised why.</p>
<p>Our goal with JBehave 2 was to make the process of collaboration, drawing up scenarios and getting started easy and simple. Feedback from enterprise users suggests that we may have succeeded!</p>
<p>Find out more about the new features, the ones we&#8217;ve discarded, and how to use it on the <a href="http://jbehave.org">JBehave site</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lizkeogh.com/2008/09/03/jbehave-20-is-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JBehave 2 is up on its usual svn</title>
		<link>http://lizkeogh.com/2008/05/29/jbehave-2-is-up-on-its-usual-svn/</link>
		<comments>http://lizkeogh.com/2008/05/29/jbehave-2-is-up-on-its-usual-svn/#comments</comments>
		<pubDate>Thu, 29 May 2008 07:48:39 +0000</pubDate>
		<dc:creator>liz</dc:creator>
				<category><![CDATA[jbehave]]></category>
		<category><![CDATA[bdd]]></category>

		<guid isPermaLink="false">http://lunivore.fbyneserv.com/?p=370</guid>
		<description><![CDATA[svn co http://svn.codehaus.org/jbehave/trunk
No &#8216;official releases&#8217; yet, but if you want to play, go ahead. Examples of examples are checked into trunk.
Features include:

 plain text scenarios
 steps defined using annotations that match the scenarios
 built on JUnit
 Ensure (which is just an extension of Assert, so you don&#8217;t have to use it)
 auto-conversion of string arguments [...]]]></description>
			<content:encoded><![CDATA[<p><em>svn co http://svn.codehaus.org/jbehave/trunk</em></p>
<p>No &#8216;official releases&#8217; yet, but if you want to play, go ahead. Examples of examples are checked into trunk.</p>
<p>Features include:</p>
<ul>
<li> plain text scenarios</li>
<li> steps defined using annotations that match the scenarios</li>
<li> built on JUnit</li>
<li> Ensure (which is just an extension of Assert, so you don&#8217;t have to use it)</li>
<li> auto-conversion of string arguments to numbers</li>
<li>pending steps generated for anything which hasn&#8217;t been defined yet (these don&#8217;t break the build)</li>
<li>errors from scenarios are rethrown after the full scenario has been described</li>
</ul>
<p>Our goal with JBehave 2 was to make a framework that was lightweight, easy to use and didn&#8217;t take as long to set up as JBehave 1. To that end, we&#8217;ve been driving this entirely from example code &#8211; no guessing, unless it&#8217;s obvious &#8211; and we&#8217;ve ended up with something that works quite a lot like RSpec&#8217;s story runner, but for Java.</p>
<ul>
<li>To use it, simply name your scenario file with underscores, eg: <code>i_can_toggle_a_cell </code>and define steps in it thus:
<pre>Given a 5 by 5 game
When I toggle the cell at (2, 3)
Then the grid should look like
.....
.....
.....
..X..
.....
When I toggle the cell at (2, 4)
Then the grid should look like
.....
.....
.....
..X..
..X..
When I toggle the cell at (2, 3)
Then the grid should look like
.....
.....
.....
.....
..X..</pre>
</li>
<li>Then extend the Scenario class with a similarly named Java class:<br />
<code>ICanToggleACell.java</code></li>
<li>Extend the Steps class &#8211; this is where your steps will be defined, and you can have as many as you want</li>
<li>Inject these into the Scenario:
<pre>public class ICanToggleACell extends Scenario {

	public ICanToggleACell() {
		super(new GridSteps()); // varargs, can have lots of steps
	}
}</pre>
</li>
<li>Annotate methods in your step class to match the ones in your plain text scenario.
<pre>public class GridSteps extends Steps {

	private Game game;
	private StringRenderer renderer;

	@Given("a $width by $height game")
	public void theGameIsRunning(int width, int height) {
		game = new Game(width, height);
		renderer = new StringRenderer();
		game.setObserver(renderer);
	}

	@When("I toggle the cell at ($ column, $row)")
	public void iToggleTheCellAt(int column, int row) {
		game.toggleCellAt(column, row);
	}

	@Then("the grid should look like $grid")
	public void theGridShouldLookLike(String grid) {
		ensureThat(renderer.asString(), equalTo(grid));
	}

}</pre>
</li>
<li>Run your new scenario!</li>
</ul>
<p>Future features we&#8217;re thinking of:</p>
<ul>
<li> having more than one scenario in a file</li>
<li> tagging scenarios</li>
<li> better tolerance of whitespace</li>
<li>an option for pending steps to break the build</li>
<li>decent documentation to show you how you can customise filename parsing, argument parsing, etc.</li>
<li> anything you persuade us you need.</li>
</ul>
<p>Give it a go and tell us what you think! Release 2.0 can&#8217;t be far away&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://lizkeogh.com/2008/05/29/jbehave-2-is-up-on-its-usual-svn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JBehave 2, naming tests and developing libraries with BDD</title>
		<link>http://lizkeogh.com/2008/04/17/jbehave-2-naming-tests-and-developing-libraries-with-bdd/</link>
		<comments>http://lizkeogh.com/2008/04/17/jbehave-2-naming-tests-and-developing-libraries-with-bdd/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 11:28:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[bdd]]></category>
		<category><![CDATA[jbehave]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Peter Bell and I had a great conversation over Skype yesterday, which he&#8217;s kindly blogged. We covered test names, and also talked about how to develop libraries using BDD. Again, this is how I do things; it&#8217;s not necessarily the only way.
Peter&#8217;s mentioned JBehave 2, so the secret&#8217;s out now &#8211; yes, it&#8217;s in progress. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pbell.com">Peter Bell</a> and I had a <a href="http://www.pbell.com/index.cfm/2008/4/17/I-Just-Got-Test-Infected-An-IM-with-Liz-Keogh">great conversation</a> over Skype yesterday, which he&#8217;s kindly blogged. We covered test names, and also talked about how to develop libraries using BDD. Again, this is how I do things; it&#8217;s not necessarily the only way.</p>
<p>Peter&#8217;s mentioned JBehave 2, so the secret&#8217;s out now &#8211; yes, it&#8217;s in progress. It&#8217;s not publically available because it&#8217;s just a spike at the moment. We&#8217;re starting afresh, learning some of the lessons that made JBehave 1.0 hard to use, taking advantage of JUnit 4&#8217;s features, and drawing heavily on the success of RSpec.</p>
<p>Our goals for JBehave 2 include:</p>
<ul>
<li>no internal support for mocking &#8211; should be able to use any of the libraries</li>
<li>extends JUnit &#8211; right-click and run both behaviours and scenarios</li>
<li>uses <a href="http://code.google.com/p/hamcrest/">Hamcrest&#8217;s</a> matchers</li>
<li>uses plain-text scenarios à la RSpec</li>
</ul>
<p>Here&#8217;s a sneak preview of the spike so far.</p>
<p>We have a scenario file, <code>i_can_toggle_a_cell</code>:</p>
<pre>Given a 5 by 5 game
When I toggle the cell at (2, 3)
Then the grid should look like
.....
.....
.....
..X..
.....
When I toggle the cell at (2, 4)
Then the grid should look like
.....
.....
.....
..X..
..X..
When I toggle the cell at (2, 3)
Then the grid should look like
.....
.....
.....
.....
..X..</pre>
<p>We have a small class in the same package to run this, called <code>ICanToggleACell.java</code> (the Scenario class is a JUnit test):<br />
<code><br />
package com.lunivore.gameoflife;</code></p>
<p><code>import org.jbehave.scenario.Scenario;</code></p>
<p><code>import com.lunivore.gameoflife.steps.GridSteps;</p>
<p>public class ICanToggleACell extends Scenario {</p>
<p></code></p>
<p> </p>
<p><code> @SuppressWarnings("unchecked")<br />
public ICanToggleACell() {<br />
super(new GridSteps());<br />
}<br />
}<br />
</code></p>
<p>And we have steps defined thus:</p>
<p><code><br />
package com.lunivore.gameoflife.steps;</code></p>
<p><code>import static org.hamcrest.CoreMatchers.equalTo;<br />
import static org.jbehave.Ensure.ensureThat;</code></p>
<p><code>import org.jbehave.scenario.annotations.Given;<br />
import org.jbehave.scenario.annotations.Then;<br />
import org.jbehave.scenario.annotations.When;<br />
import org.jbehave.scenario.steps.Steps;</p>
<p>import com.lunivore.gameoflife.domain.Game;<br />
import com.lunivore.gameoflife.view.string.StringRenderer;</p>
<p>public class GridSteps extends Steps {</p>
<p>  private Game game;<br />
  private StringRenderer renderer;</p>
<p>  @Given("a $width by $height game")<br />
  public void theGameIsRunning(int width, int height) {<br />
    game = new Game(width, height);<br />
    renderer = new StringRenderer();<br />
    game.setObserver(renderer);<br />
  }</p>
<p>  @When("I toggle the cell at ($column, $row)")<br />
  public void iToggleTheCellAt(int column, int row) {<br />
    game.toggleCellAt(column, row);<br />
  }</p>
<p>  @Then("the grid should look like $grid")<br />
  public void theGridShouldLookLike(String grid) {<br />
    ensureThat(renderer.asString(), equalTo(grid));<br />
  }</p>
<p></code></p>
<p> </p>
<p><code>}<br />
</code></p>
<p>I&#8217;m excited that this actually works. The next step is to get appropriate error messages when the scenario fails! We&#8217;re working hard to get this out to you as soon as we can; watch this space.</p>
]]></content:encoded>
			<wfw:commentRss>http://lizkeogh.com/2008/04/17/jbehave-2-naming-tests-and-developing-libraries-with-bdd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

