<?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>Richard Lawrence &#187; Cucumber</title>
	<atom:link href="http://www.richardlawrence.info/tag/cucumber/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.richardlawrence.info</link>
	<description>On making software teams happier and more productive</description>
	<lastBuildDate>Fri, 27 Jan 2012 18:41:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Cucumber Tip: IRB From Inside a Step Definition</title>
		<link>http://www.richardlawrence.info/2011/12/07/cucumber-tip-irb-from-inside-a-step-definition/</link>
		<comments>http://www.richardlawrence.info/2011/12/07/cucumber-tip-irb-from-inside-a-step-definition/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 20:05:35 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=401</guid>
		<description><![CDATA[Most Ruby programmers know about Ruby&#8217;s interactive console, IRB. (If you don&#8217;t, stop right here, open up a command window and run irb. Type some Ruby code. See how it returns the result of each line right away.) IRB is great for poking around with unfamiliar libraries. Suppose you&#8217;re using Capybara with Cucumber for the [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2010/01/12/debugging-cuke4nuke-step-definitions/' rel='bookmark' title='Permanent Link: Debugging Cuke4Nuke Step Definitions'>Debugging Cuke4Nuke Step Definitions</a></li>
<li><a href='http://www.richardlawrence.info/2011/08/20/getting-started-with-ruby-cucumber-and-capybara-on-windows/' rel='bookmark' title='Permanent Link: Getting Started with Ruby, Cucumber, and Capybara on Windows'>Getting Started with Ruby, Cucumber, and Capybara on Windows</a></li>
<li><a href='http://www.richardlawrence.info/2011/10/27/cucumber-tip-key-value-tables/' rel='bookmark' title='Permanent Link: Cucumber Tip: Key-Value Tables'>Cucumber Tip: Key-Value Tables</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>Most Ruby programmers know about Ruby&#8217;s interactive console, IRB. (If you don&#8217;t, stop right here, open up a command window and run <code class="codecolorer text default"><span class="text">irb</span></code>. Type some Ruby code. See how it returns the result of each line right away.) IRB is great for poking around with unfamiliar libraries.</p>
<p>Suppose you&#8217;re using Capybara with Cucumber for the first time. It would be nice to use IRB to experiment with what Capybara can do on a particular page. You could launch an IRB session and duplicate all the Capybara setup from your Cucumber <code class="codecolorer text default"><span class="text">support/env.rb</span></code> file. But wouldn&#8217;t it be nice if you could just fire up IRB in the context of a step definition so you know everything in your IRB session matches what you&#8217;d get in the step def? Turns out you can. Here&#8217;s how&#8230;<span id="more-401"></span></p>
<p>Install the ruby-debug gem. If you&#8217;re using Ruby 1.9 like me, you need the ruby-debug19 gem. In Rails 3, just add <code class="codecolorer text default"><span class="text">gem ruby-debug19</span></code> to your Gemfile, probably in the test group, and run <code class="codecolorer text default"><span class="text">bundle install</span></code>.</p>
<p>Require ruby-debug in <code class="codecolorer text default"><span class="text">support/env.rb</span></code>.</p>
<p>Add <code class="codecolorer text default"><span class="text">breakpoint</span></code> where you want to jump into IRB. For example:</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Given <span style="color:#006600; font-weight:bold;">/</span>^I am on the advanced search page$<span style="color:#006600; font-weight:bold;">/</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; visit <span style="color:#996600;">'http://http://www.google.com/advanced_search'</span><br />
&nbsp; breakpoint<br />
&nbsp; <span style="color:#006666;">0</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>(Note the extra line after <code class="codecolorer text default"><span class="text">breakpoint</span></code> with <code class="codecolorer text default"><span class="text">0</span></code> on it. <code class="codecolorer text default"><span class="text">breakpoint</span></code> breaks before executing the next line, so if it&#8217;s the last thing in a block, you won&#8217;t jump into the debugger in the context you expect; <code class="codecolorer text default"><span class="text">0</span></code> is a dummy line to keep us in the right context.)</p>
<p>Run Cucumber like normal. When it reaches <code class="codecolorer text default"><span class="text">breakpoint</span></code>, ruby-debug will take over, and you&#8217;ll see a prompt like this: <code class="codecolorer text default"><span class="text">(rdb:1)</span></code>.</p>
<p>You can do a lot of different things at this prompt, but we only care about one right now: type <code class="codecolorer text default"><span class="text">irb</span></code> and hit Enter. Now you should see a an IRB prompt. You&#8217;re in the context of a Cucumber step definition. Type <code class="codecolorer text default"><span class="text">self</span></code> and hit Enter. You&#8217;ll see that <code class="codecolorer text default"><span class="text">self</span></code> is an instance of Cucumber&#8217;s World with various things mixed in. From here, you can do anything you would do inside that step definition.</p>
<p>When you&#8217;re done, run <code class="codecolorer text default"><span class="text">quit</span></code> to get out of IRB and <code class="codecolorer text default"><span class="text">continue</span></code> to get out of the debugger. Cucumber execution will continue like normal. Keep in mind, though, that if you change the state of your system from IRB, you might not get the test results you expect.</p>
<p>Enhancements and variations for you to explore:</p>
<ul>
<li>Make IRB nicer to use with gems such as irbtools</li>
<li>Create a step definition just for launching the debugger</li>
<li>Create a tagged scenario just for launching the debugger</li>
</ul>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2010/01/12/debugging-cuke4nuke-step-definitions/' rel='bookmark' title='Permanent Link: Debugging Cuke4Nuke Step Definitions'>Debugging Cuke4Nuke Step Definitions</a></li>
<li><a href='http://www.richardlawrence.info/2011/08/20/getting-started-with-ruby-cucumber-and-capybara-on-windows/' rel='bookmark' title='Permanent Link: Getting Started with Ruby, Cucumber, and Capybara on Windows'>Getting Started with Ruby, Cucumber, and Capybara on Windows</a></li>
<li><a href='http://www.richardlawrence.info/2011/10/27/cucumber-tip-key-value-tables/' rel='bookmark' title='Permanent Link: Cucumber Tip: Key-Value Tables'>Cucumber Tip: Key-Value Tables</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2011/12/07/cucumber-tip-irb-from-inside-a-step-definition/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cucumber Tip: Key-Value Tables</title>
		<link>http://www.richardlawrence.info/2011/10/27/cucumber-tip-key-value-tables/</link>
		<comments>http://www.richardlawrence.info/2011/10/27/cucumber-tip-key-value-tables/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 21:38:28 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ATDD]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[Cucumber]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=375</guid>
		<description><![CDATA[You may not realize this: Tables in Cucumber steps don&#8217;t have to have a header row. Sometimes it can work really well to use a headerless table of key-value pairs. Let&#8217;s look at an example. Suppose we have a scenario that fills out an advanced search form to search for medical providers matching certain criteria. [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2010/01/04/how-to-remove-duplication-in-cucumber-tests-using-scenario-outlines/' rel='bookmark' title='Permanent Link: How to Remove Duplication in Cucumber Tests Using Scenario Outlines'>How to Remove Duplication in Cucumber Tests Using Scenario Outlines</a></li>
<li><a href='http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/' rel='bookmark' title='Permanent Link: Cuke4Nuke: Cucumber for .NET Teams'>Cuke4Nuke: Cucumber for .NET Teams</a></li>
<li><a href='http://www.richardlawrence.info/2010/07/20/just-enough-regular-expressions-for-cucumber/' rel='bookmark' title='Permanent Link: Just Enough Regular Expressions for Cucumber'>Just Enough Regular Expressions for Cucumber</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>You may not realize this: Tables in Cucumber steps don&#8217;t have to have a header row. Sometimes it can work really well to use a headerless table of key-value pairs. </p>
<p>Let&#8217;s look at an example. Suppose we have a scenario that fills out an advanced search form to search for medical providers matching certain criteria. A mockup of the form looks something like this:</p>
<p><img src="/wp-content/uploads/2011/10/medical-provider-advanced-search-form.png" alt="" title="Advanced Provider Search Mock-up" width="358" height="544" class="aligncenter size-full wp-image-378" /></p>
<p>If we were using the <a href="http://aslakhellesoy.com/post/11055981222/the-training-wheels-came-off">recently deprecated web steps</a> generated by cucumber-rails, we might write steps to perform a search like these:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Given I'm on the advanced search page<br />
And I select &quot;Endocrinology&quot; from &quot;Specialty&quot;<br />
And I choose &quot;Yes&quot; within &quot;Accepts Insurance&quot;<br />
And I fill in &quot;ZIP Code&quot; with &quot;90010&quot;<br />
And I select &quot;5 miles&quot; from &quot;Search Radius&quot;<br />
When I press &quot;Search&quot;</div></td></tr></tbody></table></div>
<p>But we know better than to do that, right? After all, we&#8217;re trying to describe how the search logic should work, not how the form should look. <span id="more-375"></span>So we try to write our own steps to do these same thing without talking about the implementation so much, but it&#8217;s really hard to get away from the implementation. Even if we drive out words like select, fill in, and click, we still have a step per form element. </p>
<p>Suppose we try to combine them into a single step for the domain concept of performing a search. We might get something like:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">When I search for an endocrinologist within 5 miles of 90010 who accepts insurance</div></td></tr></tbody></table></div>
<p>The implementation details are gone, but it&#8217;s long and hard to read. Enter the key-value table:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">When I search for a provider with the criteria:<br />
&nbsp;| Provider Type &nbsp; &nbsp; | Doctor &nbsp; &nbsp; &nbsp; &nbsp;|<br />
&nbsp;| Specialty &nbsp; &nbsp; &nbsp; &nbsp; | Endocrinology |<br />
&nbsp;| Accepts Insurance | Yes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />
&nbsp;| ZIP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | 90010 &nbsp; &nbsp; &nbsp; &nbsp; |<br />
&nbsp;| Search Radius &nbsp; &nbsp; | 5 miles &nbsp; &nbsp; &nbsp; |</div></td></tr></tbody></table></div>
<p>In the step definition, we can use the <code class="codecolorer ruby default"><span class="ruby">rows_hash</span></code> method on the table object to convert that key-value table to a single hash. There&#8217;s no need to iterate through the rows ourselves. For example, assuming a helper method called <code class="codecolorer ruby default"><span class="ruby">provider_search</span></code> that actually performs the search,</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">When</span> <span style="color:#006600; font-weight:bold;">/</span>^I search <span style="color:#9966CC; font-weight:bold;">for</span> a provider with the criteria:$<span style="color:#006600; font-weight:bold;">/</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>table<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; criteria = table.<span style="color:#9900CC;">rows_hash</span><br />
&nbsp; provider_search <span style="color:#ff3333; font-weight:bold;">:provider_type</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> criteria<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Provider Type'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:specialty</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> criteria<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Specialty'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:accepts_insurance</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> criteria<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Accepts Insurance'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_bool</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:zip_code</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> criteria<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'ZIP'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:radius</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> criteria<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Search Radius'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_i</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>You may have noticed the call to <code class="codecolorer ruby default"><span class="ruby">to_bool</span></code>. This uses a helper method like the following to allow us to use <em>yes</em> and <em>no</em> instead of <em>true</em> and <em>false</em> to make more readable scenarios. Put this somewhere in the support directory.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC0066; font-weight:bold;">String</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> to_bool<br />
&nbsp; &nbsp; !!<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span> =~ <span style="color:#006600; font-weight:bold;">/</span>^yes<span style="color:#006600; font-weight:bold;">|</span>y<span style="color:#006600; font-weight:bold;">|</span>true<span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span><span style="color:#006666;">1</span>$<span style="color:#006600; font-weight:bold;">/</span>i<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>The call to <code class="codecolorer ruby default"><span class="ruby">to_i</span></code> on the search radius takes advantage of Ruby&#8217;s string to integer conversion behavior—if a string starts with an integer but has other text after the integer, the other text is stripped off during the conversion. Try it: Fire up <code class="codecolorer text default"><span class="text">irb</span></code> (the interactive Ruby console) in a command window and run <code class="codecolorer ruby default"><span class="ruby"><span style="color:#996600;">&quot;5 miles&quot;</span>.<span style="color:#9900CC;">to_i</span></span></code>.</p>
<p>These key-value tables can get long for a complex entity. Not all the details will matter each time. We can make the step read better by introducing a concept of a default provider search. Maybe we have to supply a ZIP code and search radius, but the scenario we&#8217;re working on is really about specialties and insurance. We could say,</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">When I search for a provider with the default criteria and:<br />
&nbsp;| Provider Type &nbsp; &nbsp; | Doctor &nbsp; &nbsp; &nbsp; &nbsp;|<br />
&nbsp;| Specialty &nbsp; &nbsp; &nbsp; &nbsp; | Endocrinology |<br />
&nbsp;| Accepts Insurance | Yes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</div></td></tr></tbody></table></div>
<p>In the step definition, we&#8217;ll declare the default values in a hash and merge it with the supplied values.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">When</span> <span style="color:#006600; font-weight:bold;">/</span>^I search <span style="color:#9966CC; font-weight:bold;">for</span> a provider with the default criteria <span style="color:#9966CC; font-weight:bold;">and</span>:$<span style="color:#006600; font-weight:bold;">/</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>table<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; default_criteria = <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color:#996600;">'Provider Type'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'Doctor'</span>,<br />
&nbsp; &nbsp; <span style="color:#996600;">'Specialty'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'General'</span>,<br />
&nbsp; &nbsp; <span style="color:#996600;">'Accepts Insurance'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'Yes'</span>,<br />
&nbsp; &nbsp; <span style="color:#996600;">'ZIP'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">90010</span>,<br />
&nbsp; &nbsp; <span style="color:#996600;">'Search Radius'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'5 miles'</span><br />
&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><br />
<br />
&nbsp; criteria = default_criteria.<span style="color:#9900CC;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span>table.<span style="color:#9900CC;">rows_hash</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; provider_search <span style="color:#ff3333; font-weight:bold;">:provider_type</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> criteria<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Provider Type'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:specialty</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> criteria<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Specialty'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:accepts_insurance</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> criteria<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Accepts Insurance'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_bool</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:zip_code</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> criteria<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'ZIP'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:radius</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> criteria<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Search Radius'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_i</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>If the defaults are well known, this is enough. If they need to be documented, one way I like to do it is as executable documentation with a scenario like this:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Scenario: Default Search Criteria<br />
&nbsp; When I search for a provider with the default criteria<br />
&nbsp; Then the search criteria should include:<br />
&nbsp; &nbsp;| Provider Type &nbsp; &nbsp; | Doctor &nbsp; &nbsp; &nbsp; &nbsp;|<br />
&nbsp; &nbsp;| Specialty &nbsp; &nbsp; &nbsp; &nbsp; | General &nbsp; &nbsp; &nbsp; |<br />
&nbsp; &nbsp;| Accepts Insurance | Yes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />
&nbsp; &nbsp;| ZIP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | 90010 &nbsp; &nbsp; &nbsp; &nbsp; |<br />
&nbsp; &nbsp;| Search Radius &nbsp; &nbsp; | 5 miles &nbsp; &nbsp; &nbsp; |</div></td></tr></tbody></table></div>
<p>If you do this, you&#8217;ll want to move the default criteria hash into a helper method or constant to make sure it&#8217;s the same hash used in the real scenario and the documentation scenario.</p>
<p>We could make the step definition read better by separating the key and value conversions from the use of the data. Cucumber&#8217;s table object has <code class="codecolorer ruby default"><span class="ruby">map_headers!</span></code> and <code class="codecolorer ruby default"><span class="ruby">map_column!</span></code>. Unfortunately, those don&#8217;t work for <code class="codecolorer ruby default"><span class="ruby">rows_hash</span></code> at this time. I recently submitted a pull request to make it work. Hopefully, we&#8217;ll see that in a Cucumber release soon.</p>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2010/01/04/how-to-remove-duplication-in-cucumber-tests-using-scenario-outlines/' rel='bookmark' title='Permanent Link: How to Remove Duplication in Cucumber Tests Using Scenario Outlines'>How to Remove Duplication in Cucumber Tests Using Scenario Outlines</a></li>
<li><a href='http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/' rel='bookmark' title='Permanent Link: Cuke4Nuke: Cucumber for .NET Teams'>Cuke4Nuke: Cucumber for .NET Teams</a></li>
<li><a href='http://www.richardlawrence.info/2010/07/20/just-enough-regular-expressions-for-cucumber/' rel='bookmark' title='Permanent Link: Just Enough Regular Expressions for Cucumber'>Just Enough Regular Expressions for Cucumber</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2011/10/27/cucumber-tip-key-value-tables/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Future of Cucumber on .NET</title>
		<link>http://www.richardlawrence.info/2011/10/21/the-future-of-cucumber-on-net/</link>
		<comments>http://www.richardlawrence.info/2011/10/21/the-future-of-cucumber-on-net/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 17:56:14 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ATDD]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Cuke4Nuke]]></category>
		<category><![CDATA[SpecFlow]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=371</guid>
		<description><![CDATA[Beginning just over two years ago, I worked with some great developers to create Cuke4Nuke as a way to bring Cucumber to .NET. Shortly after the first releases of Cuke4Nuke, TechTalk released SpecFlow, a native .NET tool inspired by Cucumber. As a pure .NET solution without Ruby dependencies, SpecFlow seemed to be easier for Microsoft [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2011/03/05/cuke4nuke-needs-your-help/' rel='bookmark' title='Permanent Link: Cuke4Nuke Needs Your Help'>Cuke4Nuke Needs Your Help</a></li>
<li><a href='http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/' rel='bookmark' title='Permanent Link: Cuke4Nuke: Cucumber for .NET Teams'>Cuke4Nuke: Cucumber for .NET Teams</a></li>
<li><a href='http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/' rel='bookmark' title='Permanent Link: The Latest on Cuke4Nuke'>The Latest on Cuke4Nuke</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>Beginning just over two years ago, I worked with some great developers to create <a href="https://github.com/richardlawrence/Cuke4Nuke">Cuke4Nuke</a> as a way to bring <a href="http://cukes.info/">Cucumber</a> to .NET. Shortly after the first releases of Cuke4Nuke, TechTalk released <a href="http://www.specflow.org/">SpecFlow</a>, a native .NET tool inspired by Cucumber. As a pure .NET solution without Ruby dependencies, SpecFlow seemed to be easier for Microsoft shops to adopt. But Cuke4Nuke had (to me) enough advantages that I kept it going. </p>
<p>By this summer, however, it was clear that SpecFlow had made up for most of Cuke4Nuke&#8217;s advantages and had more momentum in the .NET community and was under much more active development. <span id="more-371"></span>There were just a few gaps SpecFlow needed to overcome (in my opinion), mostly related to better harmonization with the other Cucumber projects. (With the pure Java Cucumber-JVM under active development as a Cuke4Duke replacement, there was no longer as compelling an argument for shared code between Cucumber versions, Cuke4Nuke&#8217;s biggest remaining advantage.)</p>
<p>At AA-FTT and later in the week at Agile 2011, my colleague <a href="http://www.virtual-genius.com">Paul Rayner</a> and I met with Christian Hassa and Gaspar Nagy from the SpecFlow team. We discussed the few things that needed to change in SpecFlow to make it behave more like the other Cucumbers. </p>
<p>This week, most of those changes were released as part of SpecFlow 1.8. With that release, I&#8217;m letting Cuke4Nuke die. I won&#8217;t be maintaining or extending Cuke4Nuke. My Cucumber classes and book will cover SpecFlow rather than Cuke4Nuke. </p>
<p>I&#8217;ve had a great time getting to know the SpecFlow guys, and I look forward to collaborating with them in the future to help bring Cucumber to more and more teams in the Microsoft world.</p>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2011/03/05/cuke4nuke-needs-your-help/' rel='bookmark' title='Permanent Link: Cuke4Nuke Needs Your Help'>Cuke4Nuke Needs Your Help</a></li>
<li><a href='http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/' rel='bookmark' title='Permanent Link: Cuke4Nuke: Cucumber for .NET Teams'>Cuke4Nuke: Cucumber for .NET Teams</a></li>
<li><a href='http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/' rel='bookmark' title='Permanent Link: The Latest on Cuke4Nuke'>The Latest on Cuke4Nuke</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2011/10/21/the-future-of-cucumber-on-net/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Cucumber Regular Expressions Cheat Sheet</title>
		<link>http://www.richardlawrence.info/2011/08/23/cucumber-regular-expressions-cheat-sheet/</link>
		<comments>http://www.richardlawrence.info/2011/08/23/cucumber-regular-expressions-cheat-sheet/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 15:39:56 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=356</guid>
		<description><![CDATA[Regular expressions are a big part of what makes Cucumber tests both expressive in English and DRY on the automation side. To make the most of that power, you have to know something about regular expressions. I&#8217;ve created a cheat sheet for my Cucumber class workbook based on last year&#8217;s &#8220;Just Enough Regular Expressions for [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2010/07/20/just-enough-regular-expressions-for-cucumber/' rel='bookmark' title='Permanent Link: Just Enough Regular Expressions for Cucumber'>Just Enough Regular Expressions for Cucumber</a></li>
<li><a href='http://www.richardlawrence.info/2011/08/20/getting-started-with-ruby-cucumber-and-capybara-on-windows/' rel='bookmark' title='Permanent Link: Getting Started with Ruby, Cucumber, and Capybara on Windows'>Getting Started with Ruby, Cucumber, and Capybara on Windows</a></li>
<li><a href='http://www.richardlawrence.info/2009/09/02/resources-from-our-agile-2009-presentation/' rel='bookmark' title='Permanent Link: Resources from our Agile 2009 Presentation'>Resources from our Agile 2009 Presentation</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>Regular expressions are a big part of what makes Cucumber tests both expressive in English and <a href="http://books.google.com/books?id=5wBQEp6ruIAC&#038;lpg=PA27&#038;dq=dry%20pragmatic%20programmer&#038;pg=PA27#v=onepage&#038;q=dry%20pragmatic%20programmer&#038;f=false">DRY</a> on the automation side. To make the most of that power, you have to know something about regular expressions. </p>
<p>I&#8217;ve created a cheat sheet for my Cucumber class workbook based on last year&#8217;s &#8220;<a href="/2010/07/20/just-enough-regular-expressions-for-cucumber/">Just Enough Regular Expressions for Cucumber</a>&#8221; post. Download and print a copy to post by your computer until regular expressions become natural for you:</p>
<p><a href='/wp-content/uploads/2011/08/Cucumber-Regular-Expressions-Cheat-Sheet.pdf'>Cucumber Regular Expressions Cheat Sheet</a></p>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2010/07/20/just-enough-regular-expressions-for-cucumber/' rel='bookmark' title='Permanent Link: Just Enough Regular Expressions for Cucumber'>Just Enough Regular Expressions for Cucumber</a></li>
<li><a href='http://www.richardlawrence.info/2011/08/20/getting-started-with-ruby-cucumber-and-capybara-on-windows/' rel='bookmark' title='Permanent Link: Getting Started with Ruby, Cucumber, and Capybara on Windows'>Getting Started with Ruby, Cucumber, and Capybara on Windows</a></li>
<li><a href='http://www.richardlawrence.info/2009/09/02/resources-from-our-agile-2009-presentation/' rel='bookmark' title='Permanent Link: Resources from our Agile 2009 Presentation'>Resources from our Agile 2009 Presentation</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2011/08/23/cucumber-regular-expressions-cheat-sheet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting Started with Ruby, Cucumber, and Capybara on Windows</title>
		<link>http://www.richardlawrence.info/2011/08/20/getting-started-with-ruby-cucumber-and-capybara-on-windows/</link>
		<comments>http://www.richardlawrence.info/2011/08/20/getting-started-with-ruby-cucumber-and-capybara-on-windows/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 15:23:20 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Capybara]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=348</guid>
		<description><![CDATA[The Ruby version of Cucumber isn&#8217;t just for Rails developers. If you have a .NET or Java web or service app, Ruby can be a great language for testing. With libraries like Capybara for driving web apps and JSON, RestClient, SOAP, and others for interacting with service apps, you&#8217;ll find testing in Ruby requires much [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/' rel='bookmark' title='Permanent Link: The Latest on Cuke4Nuke'>The Latest on Cuke4Nuke</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>The Ruby version of Cucumber isn&#8217;t just for Rails developers. If you have a .NET or Java web or service app, Ruby can be a great language for testing. With libraries like Capybara for driving web apps and JSON, RestClient, SOAP, and others for interacting with service apps, you&#8217;ll find testing in Ruby requires much less code than in C# or Java.</p>
<p>It can be hard to find instructions for setting up Ruby and Cucumber on Windows, though, so I&#8217;ve compiled these to help my clients get started, and I thought they might be useful to others. I&#8217;ve tested this on a clean Windows 7 VM, and everything works. Your mileage may vary, but let me know if you have any issues. <span id="more-348"></span></p>
<ol>
<li>You&#8217;re going to be working in a command window quite a bit with Cucumber. You may want to customize your command window to make it more pleasant to use. I like the following settings (right click on the top left corner of the command window and choose Properties to set these):<br />
Font: Consolas, 20pt<br />
Screen Buffer: 120&#215;3000<br />
Window Size: 120&#215;60</p>
<p>On a smaller screen, you&#8217;ll of course want a smaller window size and screen buffer. If you&#8217;re on an earlier version of Windows, you won&#8217;t be able to choose Consolas for the font, but Lucida Console is still better than the default.</p>
<p>I also like to set a PROMPT environment variable to <code class="codecolorer text default"><span class="text">$P$_$+$G</span></code> (right click on My Computer and choose Properties, then Advanced, then Environment Variables).</li>
<li> Download and install Ruby. For Windows, <a href="http://rubyinstaller.org/">http://rubyinstaller.org/</a> is the best option. Install the latest release of version 1.9.2. Make sure you check the option to &#8220;Add Ruby executables to your PATH.&#8221;</li>
<li> Also install the Ruby Development Kit from the same place, which will allow Ruby to build native extensions for libraries. Instructions are available here: <a href="https://github.com/oneclick/rubyinstaller/wiki/Development-Kit">https://github.com/oneclick/rubyinstaller/wiki/Development-Kit</a>.</li>
<li> Confirm that the installation worked by opening a command window and running <code class="codecolorer text default"><span class="text">ruby -v</span></code>. You should see a description of the Ruby version installed. If you see an error, something went wrong with the installation.</li>
<li> Make sure you have RubyGems installed by running <code class="codecolorer text default"><span class="text">gem -v</span></code> on a command line. RubyGems is the package manager for Ruby and should come with the standard Ruby installation.</li>
<li> Run <code class="codecolorer text default"><span class="text">gem install cucumber</span></code> to download and install Cucumber. Run <code class="codecolorer text default"><span class="text">cucumber --help</span></code> to confirm that it worked.</li>
<li> Cucumber complains that you need ANSICON to get console colors because Windows doesn&#8217;t understand ANSI color escape sequences. Download ANSICON from <a href="http://adoxa.110mb.com/ansicon/index.html">http://adoxa.110mb.com/ansicon/index.html</a>. Extract it somewhere (I put it in c:\utils\). In your command window, <code class="codecolorer text default"><span class="text">cd</span></code> to either the x86 or x64 directory where you extracted ANSICON, depending on your OS, and run <code class="codecolorer text default"><span class="text">ansicon -i</span></code>. Exit that command window and open a new one. Now, when you run <code class="codecolorer text default"><span class="text">cucumber --help</span></code>, you should no longer see the message in the output about needing ANSICON.</li>
<li> Run <code class="codecolorer text default"><span class="text">gem install capybara</span></code> to download and install the Capybara web automation library.</li>
<li> Run <code class="codecolorer text default"><span class="text">gem install rspec</span></code> to download and install a nice library for readable assertions (among other things).</li>
<li> You&#8217;ll want <a href="http://www.getfirefox.com/">Firefox</a> with the <a href="http://www.getfirebug.com/">Firebug</a> plugin to do UI-related tests. If you haven&#8217;t already, install those.</li>
<li> You can edit Cucumber tests and automation code in Notepad, Visual Studio, or any other text editor. But I like having an editor that knows about Cucumber and provides Cucumber-oriented features, so I use <a href="http://www.jetbrains.com/ruby/">JetBrains RubyMine</a> to work with my Cucumber tests. There&#8217;s a free 30 day trial available.</li>
<li> To make sure Cucumber and Capybara are working nicely together, download and extract this <a href="http://www.richardlawrence.info/wp-content/uploads/2011/08/ruby-capybara.zip">Ruby, Cucumber, and Capybara Starter Project</a> somewhere on your machine. Open a command window at the root of the folder (if you run <code class="codecolorer text default"><span class="text">dir</span></code> or <code class="codecolorer text default"><span class="text">ls</span></code> there, you should see a &#8220;features&#8221; folder). Run <code class="codecolorer text default"><span class="text">cucumber</span></code>, and you should see all the tests run and pass.</li>
</ol>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/' rel='bookmark' title='Permanent Link: The Latest on Cuke4Nuke'>The Latest on Cuke4Nuke</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2011/08/20/getting-started-with-ruby-cucumber-and-capybara-on-windows/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Cuke4Nuke Needs Your Help</title>
		<link>http://www.richardlawrence.info/2011/03/05/cuke4nuke-needs-your-help/</link>
		<comments>http://www.richardlawrence.info/2011/03/05/cuke4nuke-needs-your-help/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 18:04:45 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ATDD]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Cuke4Nuke]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=333</guid>
		<description><![CDATA[Almost 2 years ago, at the 2009 AA-FTT conference, I started Cuke4Nuke to bring Cucumber to the .NET world. Since then, thanks to some fantastic help from Aslak Hellesøy, Matt Wynne, Declan Whelan, Åsmund Eldhuset, and others, Cuke4Nuke supports almost all the features of Cucumber. But there are still a few key features it needs, [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/' rel='bookmark' title='Permanent Link: Cuke4Nuke: Cucumber for .NET Teams'>Cuke4Nuke: Cucumber for .NET Teams</a></li>
<li><a href='http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/' rel='bookmark' title='Permanent Link: The Latest on Cuke4Nuke'>The Latest on Cuke4Nuke</a></li>
<li><a href='http://www.richardlawrence.info/2010/01/12/debugging-cuke4nuke-step-definitions/' rel='bookmark' title='Permanent Link: Debugging Cuke4Nuke Step Definitions'>Debugging Cuke4Nuke Step Definitions</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>Almost 2 years ago, at the 2009 AA-FTT conference, I started <a href="https://github.com/richardlawrence/Cuke4Nuke/wiki">Cuke4Nuke</a> to bring <a href="http://cukes.info/">Cucumber</a> to the .NET world. Since then, thanks to some fantastic help from Aslak Hellesøy, Matt Wynne, Declan Whelan, Åsmund Eldhuset, and others, Cuke4Nuke supports almost all the features of Cucumber.</p>
<p>But there are still a few key features it needs, and I have too many projects going to keep up with it. Specifically, I&#8217;d most like to see:</p>
<ul>
<li>Support for VS2010 (.NET 4) and Mono</li>
<li>Step definition config files</li>
<li>Tagged hooks</li>
<li>An all-in-one installer like RailsInstaller </li>
<li>Better UTF-8 support</li>
<li>Culture support to go with the current language support (e.g. for string to decimal or date conversions)</li>
<li>Debugging for step definitions in Visual Studio</li>
<li>A completely automated build and release process for Cuke4Nuke itself</li>
<li>Updates to <a href="https://github.com/henritersteeg/cuke4vs">cuke4vs</a>, which isn&#8217;t my project but which brings valuable Visual Studio integration to Cuke4Nuke</li>
</ul>
<p>Are you a .NET and/or Ruby developer? Would you like to contribute? I&#8217;d love the help. Check out the <a href="https://github.com/richardlawrence/Cuke4Nuke/wiki/Contributing">instructions for contributing</a> and jump in!</p>
<p>P.S. &#8211; Since someone always asks&#8230;Yes, I know about SpecFlow. I think it&#8217;s a great project. But I still believe there&#8217;s value in a .NET version of Cucumber that shares as much code and behavior as possible with the main Cucumber project.</p>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/' rel='bookmark' title='Permanent Link: Cuke4Nuke: Cucumber for .NET Teams'>Cuke4Nuke: Cucumber for .NET Teams</a></li>
<li><a href='http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/' rel='bookmark' title='Permanent Link: The Latest on Cuke4Nuke'>The Latest on Cuke4Nuke</a></li>
<li><a href='http://www.richardlawrence.info/2010/01/12/debugging-cuke4nuke-step-definitions/' rel='bookmark' title='Permanent Link: Debugging Cuke4Nuke Step Definitions'>Debugging Cuke4Nuke Step Definitions</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2011/03/05/cuke4nuke-needs-your-help/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Public ATDD with Cucumber Course, March 7-8, Denver (Postponed)</title>
		<link>http://www.richardlawrence.info/2011/01/12/public-atdd-with-cucumber-course-march-denver/</link>
		<comments>http://www.richardlawrence.info/2011/01/12/public-atdd-with-cucumber-course-march-denver/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 23:51:12 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=328</guid>
		<description><![CDATA[Update: This course has been postponed until June or July. If you&#8217;re interested in attending, let me know and I&#8217;ll notify you when registration opens so you can take advantage of the early bird discount. I&#8217;m hosting a public course on Acceptance Test Driven Development with Cucumber (mostly Java-focused) on March 7 and 8 in [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2008/10/30/free-agile-product-management-seminar-nov-11-denver/' rel='bookmark' title='Permanent Link: Free Agile Product Management Seminar &#8211; Nov 11, Denver'>Free Agile Product Management Seminar &#8211; Nov 11, Denver</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p><strong>Update: This course has been postponed until June or July. If you&#8217;re interested in attending, <a href="/contact/">let me know</a> and I&#8217;ll notify you when registration opens so you can take advantage of the early bird discount.</strong></p>
<p>I&#8217;m hosting a <a href="http://atddwithcucumber-denver-march2011-bl.eventbrite.com">public course on Acceptance Test Driven Development with Cucumber</a> (mostly Java-focused) on March 7 and 8 in Denver. Register by February 7 for the 10% early bird discount. </p>
<p>The course is eligible for Colorado Workforce Investment Act funds; if you&#8217;re unemployed, you might be able to attend for free. Don&#8217;t waste any time getting started, though. It can take more than a month to get WIA training approved in some counties. <a href="/contact/">Contact me</a> for more info on this option.</p>
<p>Hope to see you there!</p>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2008/10/30/free-agile-product-management-seminar-nov-11-denver/' rel='bookmark' title='Permanent Link: Free Agile Product Management Seminar &#8211; Nov 11, Denver'>Free Agile Product Management Seminar &#8211; Nov 11, Denver</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2011/01/12/public-atdd-with-cucumber-course-march-denver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Just Enough Regular Expressions for Cucumber</title>
		<link>http://www.richardlawrence.info/2010/07/20/just-enough-regular-expressions-for-cucumber/</link>
		<comments>http://www.richardlawrence.info/2010/07/20/just-enough-regular-expressions-for-cucumber/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 21:38:50 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ATDD]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Cuke4Nuke]]></category>
		<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=261</guid>
		<description><![CDATA[Jon Archer wrote last week about how Cucumber makes knowledge of regular expressions important. He&#8217;s right: Regular expressions are the key to Cucumber&#8217;s flexibility. Well-crafted regular expressions let you reuse step definitions, avoiding duplication and keeping your tests maintainable. But even experienced developers find them mysterious and overwhelming. Fortunately, you don&#8217;t need regular expressions like [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/' rel='bookmark' title='Permanent Link: Cuke4Nuke: Cucumber for .NET Teams'>Cuke4Nuke: Cucumber for .NET Teams</a></li>
<li><a href='http://www.richardlawrence.info/2010/01/12/debugging-cuke4nuke-step-definitions/' rel='bookmark' title='Permanent Link: Debugging Cuke4Nuke Step Definitions'>Debugging Cuke4Nuke Step Definitions</a></li>
<li><a href='http://www.richardlawrence.info/2010/01/04/how-to-remove-duplication-in-cucumber-tests-using-scenario-outlines/' rel='bookmark' title='Permanent Link: How to Remove Duplication in Cucumber Tests Using Scenario Outlines'>How to Remove Duplication in Cucumber Tests Using Scenario Outlines</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>Jon Archer wrote last week about how <a href="http://www.jonarcher.com/2010/07/cucumbers-and-why-it-suddenly-matters.html">Cucumber makes knowledge of regular expressions important</a>. He&#8217;s right: Regular expressions are the key to Cucumber&#8217;s flexibility. Well-crafted regular expressions let you reuse step definitions, avoiding duplication and keeping your tests maintainable. But even experienced developers find them mysterious and overwhelming.</p>
<p>Fortunately, you don&#8217;t need regular expressions like this one to wield the power of Cucumber:</p>
<div class="codecolorer-container text default" style="border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">(?:[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*|&quot;(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*&quot;)@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])</div></td></tr></tbody></table></div>
<p>In fact, if you use regular expressions like this in your step definitions, you&#8217;ve gone too far. (This regular expression, in case you&#8217;re wondering, matches the official spec for valid email addresses.)</p>
<p>As with most things, the 80/20 rule applies. There are a handful of useful patterns that are sufficient to make you a Cucumber power user. <span id="more-261"></span></p>
<h3>Anchors</h3>
<p>The regular expression <code class="codecolorer text default"><span class="text">I'm logged in</span></code> matches <code class="codecolorer text default"><span class="text">I'm logged in</span></code> and <code class="codecolorer text default"><span class="text">I'm logged in as an admin</span></code>. To avoid ambiguous matches, use <code class="codecolorer text default"><span class="text">^I'm logged in$</span></code>.</p>
<p>The caret at the beginning anchors to the beginning of the string. The dollar at the end does the same with the end of the string. Use these with all your step definitions and you won&#8217;t have surprise matches.</p>
<h3>Wildcards and quantifiers</h3>
<p>Matching specific words is fine. But you often want flexibility to match a variety of strings. Here are some common patterns for non-exact matches.</p>
<table border="0">
<tr>
<td><code class="codecolorer text default"><span class="text">.*</span></code></td>
<td>matches anything (or nothing), literally &#8220;any character (except a newline) 0 or more times&#8221;</td>
</tr>
<tr>
<td><code class="codecolorer text default"><span class="text">.+</span></code></td>
<td>matches at least one of anything</td>
</tr>
<tr>
<td nowrap="true" style="padding-right:1em;"><code class="codecolorer text default"><span class="text">[0-9]*</span></code> or <code class="codecolorer text default"><span class="text">\d*</span></code></td>
<td>matches a series of digits (or nothing)</td>
</tr>
<tr>
<td><code class="codecolorer text default"><span class="text">[0-9]+</span></code> or <code class="codecolorer text default"><span class="text">\d+</span></code></td>
<td>matches one or more digits</td>
</tr>
<tr>
<td><code class="codecolorer text default"><span class="text">&quot;[^\&quot;]*&quot;</span></code></td>
<td>matches something (or nothing) in double quotes</td>
</tr>
<tr>
<td><code class="codecolorer text default"><span class="text">an?</span></code></td>
<td>matches <em>a</em> or <em>an</em> (the question mark makes the <em>n</em> optional)</td>
</tr>
</table>
<p>&nbsp;</p>
<h3>Capturing and not capturing</h3>
<p>When you put part of a regular expression in parentheses, whatever it matches gets captured for use later. This is known as a &#8220;capture group.&#8221; In Cucumber, captured strings become step definition parameters. Typically, if you&#8217;re using a wildcard, you probably want to capture the matching value for use in your step definition. Here&#8217;s a Cuke4Nuke example,</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">&#91;</span>Given<span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;^I'm logged in as an? (.*)$&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> ImLoggedInAsA<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> role<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; <span style="color: #008080; font-style: italic;">// log in as the given role</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>If your step is <code class="codecolorer text default"><span class="text">Given I'm logged in as an admin</span></code>, then the step definition gets passed <code class="codecolorer csharp default"><span class="csharp"><span style="color: #666666;">&quot;admin&quot;</span></span></code> for <code class="codecolorer csharp default"><span class="csharp">role</span></code>.</p>
<p>Cuke4Nuke converts captured strings to the step definition parameter type, which is handy for step definitions like this:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">&#91;</span>Given<span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;^I have (\d+) cukes$&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> IHaveNCukes<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> cukeCount<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; <span style="color: #008080; font-style: italic;">// set up the given number of cukes</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>The step <code class="codecolorer text default"><span class="text">Given I have 42 cukes</span></code> means the step definition gets called with <code class="codecolorer csharp default"><span class="csharp"><span style="color: #FF0000;">42</span></span></code> (as an integer) for <code class="codecolorer csharp default"><span class="csharp">cukeCount</span></code>.</p>
<p>Sometimes, you have to use parentheses to get a regular expression to work, but you don&#8217;t want to capture the match.</p>
<p>For example, suppose I want to be able to match both <code class="codecolorer text default"><span class="text">When I log in as an admin</span></code> and <code class="codecolorer text default"><span class="text">Given I'm logged in as an admin</span></code>. After all, both step definitions do the same thing. There&#8217;s no reason to have duplicated automation code in my step definitions simply because one is a Given and one is a When.</p>
<p>I might write something like this:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">&#91;</span>When<span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;^(I'm logged|I log) in as an? (.*)$&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> LogInAs<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> role<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; <span style="color: #008080; font-style: italic;">// log in as the given role</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>The parentheses and pipe indicate a logical OR, just what I need to match two different strings.</p>
<p>This will fail to run, though. My regular expression is capturing two strings, but my step definition method only takes one. I need to designate the first group as non-capturing like this:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">&#91;</span>When<span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;^(?:I'm logged|I log) in as an? (.*)$&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> LogInAs<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> role<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; <span style="color: #008080; font-style: italic;">// log in as the given role</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Now, with the addition of <code class="codecolorer text default"><span class="text">?:</span></code> at the beginning of the group, it will perform as I expect.</p>
<p>By the way: You may be wondering how the attribute can be When and still match <code class="codecolorer text default"><span class="text">Given I'm logged in as an admin</span></code>. It turns out that in Cuke4Nuke, just like in Cucumber for Ruby, it doesn&#8217;t matter whether you use Given, When, or Then to define a step definition. They&#8217;re all step definitions and are interchangeable. It&#8217;s fairly common for today&#8217;s When to be tomorrow&#8217;s Given, so this is a nice feature.</p>
<h3>Just enough</h3>
<p>This is only the tip of the regular expression iceberg. Here&#8217;s a <a href="http://www.amazon.com/exec/obidos/ASIN/0596520689">book</a> and <a href="http://www.regular-expressions.info/">website</a> if you&#8217;re interested in going deeper. But for day-to-day work with Cucumber, anchors, simple wildcards and quantifiers, and capturing and non-capturing groups are all you need.</p>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/' rel='bookmark' title='Permanent Link: Cuke4Nuke: Cucumber for .NET Teams'>Cuke4Nuke: Cucumber for .NET Teams</a></li>
<li><a href='http://www.richardlawrence.info/2010/01/12/debugging-cuke4nuke-step-definitions/' rel='bookmark' title='Permanent Link: Debugging Cuke4Nuke Step Definitions'>Debugging Cuke4Nuke Step Definitions</a></li>
<li><a href='http://www.richardlawrence.info/2010/01/04/how-to-remove-duplication-in-cucumber-tests-using-scenario-outlines/' rel='bookmark' title='Permanent Link: How to Remove Duplication in Cucumber Tests Using Scenario Outlines'>How to Remove Duplication in Cucumber Tests Using Scenario Outlines</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2010/07/20/just-enough-regular-expressions-for-cucumber/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Debugging Cuke4Nuke Step Definitions</title>
		<link>http://www.richardlawrence.info/2010/01/12/debugging-cuke4nuke-step-definitions/</link>
		<comments>http://www.richardlawrence.info/2010/01/12/debugging-cuke4nuke-step-definitions/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 02:52:51 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Cuke4Nuke]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[WatiN]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=255</guid>
		<description><![CDATA[At a client today, we were doing some tricky automation with WatiN (against Telerik controls) in Cuke4Nuke. We wanted to dig into what WatiN was finding in the browser. The obvious move was to fire up the debugger. But with Cuke4Nuke, this is trickier than you might think. The Cuke4Nuke gem includes a release build—no [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/' rel='bookmark' title='Permanent Link: The Latest on Cuke4Nuke'>The Latest on Cuke4Nuke</a></li>
<li><a href='http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/' rel='bookmark' title='Permanent Link: Cuke4Nuke: Cucumber for .NET Teams'>Cuke4Nuke: Cucumber for .NET Teams</a></li>
<li><a href='http://www.richardlawrence.info/2009/12/03/screencast-testing-web-applications-in-net-with-cuke4nuke-and-watin/' rel='bookmark' title='Permanent Link: Screencast: Testing Web Applications in .NET with Cuke4Nuke and WatiN'>Screencast: Testing Web Applications in .NET with Cuke4Nuke and WatiN</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>At a client today, we were doing some tricky automation with WatiN (against Telerik controls) in Cuke4Nuke. We wanted to dig into what WatiN was finding in the browser. The obvious move was to fire up the debugger. But with Cuke4Nuke, this is trickier than you might think. The Cuke4Nuke gem includes a release build—no debug symbols. Plus, the process isn&#8217;t around long enough to attach to if you use the cuke4nuke executable. We probably could have figured it out, but it wasn&#8217;t worth the trouble.</p>
<p>Since we weren&#8217;t debugging the Cucumber side of things, we didn&#8217;t need all the Cucumber and Cuke4Nuke plumbing. We just needed to run the code using WatiN.</p>
<p>NUnit and Resharper to the rescue&#8230;Cuke4Nuke cares about Given, When, Then, Before, and After attributes on your methods. But that doesn&#8217;t mean those are the only attributes allowed. <span id="more-255"></span></p>
<p>We added a TestFixture attribute to the class. We put SetUp and TearDown attributes on the Before and After methods. We created a new method with a Test attribute that called the relevant step definition methods. Set a breakpoint, click the Resharper test icon and choose Debug, and next thing we knew we were debugging our way through the step definition code.</p>
<p>Next time you need to debug a tricky step definition, don&#8217;t bother trying to get Cuke4Nuke in the debugger. Just use your unit test framework to call your step definitions. It&#8217;s faster to set up and faster to run.</p>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/' rel='bookmark' title='Permanent Link: The Latest on Cuke4Nuke'>The Latest on Cuke4Nuke</a></li>
<li><a href='http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/' rel='bookmark' title='Permanent Link: Cuke4Nuke: Cucumber for .NET Teams'>Cuke4Nuke: Cucumber for .NET Teams</a></li>
<li><a href='http://www.richardlawrence.info/2009/12/03/screencast-testing-web-applications-in-net-with-cuke4nuke-and-watin/' rel='bookmark' title='Permanent Link: Screencast: Testing Web Applications in .NET with Cuke4Nuke and WatiN'>Screencast: Testing Web Applications in .NET with Cuke4Nuke and WatiN</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2010/01/12/debugging-cuke4nuke-step-definitions/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to Remove Duplication in Cucumber Tests Using Scenario Outlines</title>
		<link>http://www.richardlawrence.info/2010/01/04/how-to-remove-duplication-in-cucumber-tests-using-scenario-outlines/</link>
		<comments>http://www.richardlawrence.info/2010/01/04/how-to-remove-duplication-in-cucumber-tests-using-scenario-outlines/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 17:09:36 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Cuke4Nuke]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[WatiN]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=249</guid>
		<description><![CDATA[Gojko Adzic has a new blog post demonstrating the new table parameter support in Cuke4Nuke. Table parameters are an important part of Cucumber. They&#8217;re great for setting up data and asserting that lists are what you expect. But I use them much less often than the other kind of table in Cucumber, scenario outlines. Scenario [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/' rel='bookmark' title='Permanent Link: The Latest on Cuke4Nuke'>The Latest on Cuke4Nuke</a></li>
<li><a href='http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/' rel='bookmark' title='Permanent Link: Cuke4Nuke: Cucumber for .NET Teams'>Cuke4Nuke: Cucumber for .NET Teams</a></li>
<li><a href='http://www.richardlawrence.info/2009/12/03/screencast-testing-web-applications-in-net-with-cuke4nuke-and-watin/' rel='bookmark' title='Permanent Link: Screencast: Testing Web Applications in .NET with Cuke4Nuke and WatiN'>Screencast: Testing Web Applications in .NET with Cuke4Nuke and WatiN</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>Gojko Adzic has a <a href="http://gojko.net/2010/01/04/bdd-in-net-with-cucumber-part-2-making-scenarios-easier-to-read-with-tables/">new blog post</a> demonstrating the new table parameter support in Cuke4Nuke. Table parameters are an important part of Cucumber. They&#8217;re great for setting up data and asserting that lists are what you expect. But I use them much less often than the other kind of table in Cucumber, scenario outlines. <span id="more-249"></span></p>
<p>Scenario outlines are the solution to repetitive Given-When-Then scenarios. Extending the WatiN example in <a href="/2009/12/03/screencast-testing-web-applications-in-net-with-cuke4nuke-and-watin/">my previous screencast</a>, we might find ourselves writing scenarios like:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Scenario: Search - richard lawrence<br />
&nbsp; Given I'm on the search page<br />
&nbsp; When I search for &quot;richard lawrence&quot;<br />
&nbsp; Then I should see &quot;www.richardlawrence.info&quot; in the results<br />
<br />
Scenario: Search - pickaxe<br />
&nbsp; Given I'm on the search page<br />
&nbsp; When I search for &quot;pickaxe&quot;<br />
&nbsp; Then I should see &quot;www.ruby-doc.org/docs/ProgrammingRuby/&quot; in the results<br />
<br />
Scenario: Search - cuke4nuke<br />
&nbsp; Given I'm on the search page<br />
&nbsp; When I search for &quot;cuke4nuke&quot;<br />
&nbsp; Then I should see &quot;github.com/richardlawrence/Cuke4Nuke&quot; in the results</div></td></tr></tbody></table></div>
<p>This kind of repetition gets old fast, both to write and to read. Scenario outlines allow us to separate the structure of the test, which doesn&#8217;t change, from the data, which does. Here are the same scenarios refactored:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Scenario Outline: Search<br />
&nbsp; Given I'm on the search page<br />
&nbsp; When I search for &quot;&lt;query&gt;&quot;<br />
&nbsp; Then I should see &quot;&lt;expected_result&gt;&quot; in the results<br />
<br />
&nbsp; Examples:<br />
&nbsp; | query &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| expected_result &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />
&nbsp; | richard lawrence | www.richardlawrence.info &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />
&nbsp; | pickaxe &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| www.ruby-doc.org/docs/ProgrammingRuby/ |<br />
&nbsp; | cuke4nuke &nbsp; &nbsp; &nbsp; &nbsp;| github.com/richardlawrence/Cuke4Nuke &nbsp; |</div></td></tr></tbody></table></div>
<p>Cucumber turns each example—each table row—into a concrete scenario before looking for matching step definitions in Cuke4Nuke, so nothing needs to change on the Cuke4Nuke side.</p>
<p>In most cases, I recommend starting with concrete scenarios and refactoring to scenario outlines once you have a few scenarios working with the correct step definitions.</p>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/' rel='bookmark' title='Permanent Link: The Latest on Cuke4Nuke'>The Latest on Cuke4Nuke</a></li>
<li><a href='http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/' rel='bookmark' title='Permanent Link: Cuke4Nuke: Cucumber for .NET Teams'>Cuke4Nuke: Cucumber for .NET Teams</a></li>
<li><a href='http://www.richardlawrence.info/2009/12/03/screencast-testing-web-applications-in-net-with-cuke4nuke-and-watin/' rel='bookmark' title='Permanent Link: Screencast: Testing Web Applications in .NET with Cuke4Nuke and WatiN'>Screencast: Testing Web Applications in .NET with Cuke4Nuke and WatiN</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2010/01/04/how-to-remove-duplication-in-cucumber-tests-using-scenario-outlines/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

