<?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; .NET</title>
	<atom:link href="http://www.richardlawrence.info/tag/net/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>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>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>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>The Latest on Cuke4Nuke</title>
		<link>http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/</link>
		<comments>http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 17:42:38 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[BDD]]></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=245</guid>
		<description><![CDATA[This morning, I released version 0.3.0 of Cuke4Nuke. With this release, Cuke4Nuke supports almost everything you can do with Cucumber in Ruby or Java, making C# a first class language for Cucumber. (The only missing features are small things like tags on Before and After hooks and a richer Table object.) Check out the Cuke4Nuke [...]


Related posts:<ol><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>
<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/01/19/web-testing-for-net-teams-watin-or-watir/' rel='bookmark' title='Permanent Link: Web Testing for .NET Teams: WatiN or Watir?'>Web Testing for .NET Teams: WatiN or Watir?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>This morning, I released version 0.3.0 of <a href="http://wiki.github.com/richardlawrence/Cuke4Nuke">Cuke4Nuke</a>. With this release, Cuke4Nuke supports almost everything you can do with <a href="http://cukes.info/">Cucumber</a> in Ruby or Java, making C# a first class language for Cucumber. (The only missing features are small things like tags on Before and After hooks and a richer Table object.) Check out the <a href="http://wiki.github.com/richardlawrence/Cuke4Nuke">Cuke4Nuke wiki</a> for instructions to install and get started with Cucumber in .NET. To see it in action, check out my <a href="/2009/12/03/screencast-testing-web-applications-in-net-with-cuke4nuke-and-watin/">screencast on Cuke4Nuke and WatiN</a>.</p>


<p>Related posts:<ol><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>
<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/01/19/web-testing-for-net-teams-watin-or-watir/' rel='bookmark' title='Permanent Link: Web Testing for .NET Teams: WatiN or Watir?'>Web Testing for .NET Teams: WatiN or Watir?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2009/12/30/the-latest-on-cuke4nuke/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WatiN Patterns #3: Don&#8217;t Over-specify</title>
		<link>http://www.richardlawrence.info/2009/10/30/watin-patterns-3-dont-over-specify/</link>
		<comments>http://www.richardlawrence.info/2009/10/30/watin-patterns-3-dont-over-specify/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 15:20:31 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[WatiN]]></category>
		<category><![CDATA[WatiN Patterns]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=202</guid>
		<description><![CDATA[After a long hiatus, I&#8217;m resuming the WatiN Patterns series. Pattern #1 covered why and how your tests should clean up after themselves. Pattern #2 covered how you should name your tests and why they should only assert one thing. Pattern #3 is about keeping your tests maintainable by specifying just enough in your element [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/02/11/watin-patterns-2-one-assertion-and-a-name-to-match/' rel='bookmark' title='Permanent Link: WatiN Patterns #2: One Assertion and a Name to Match'>WatiN Patterns #2: One Assertion and a Name to Match</a></li>
<li><a href='http://www.richardlawrence.info/2009/02/04/watin-patterns-1-no-browser-left-behind/' rel='bookmark' title='Permanent Link: WatiN Patterns #1: No Browser Left Behind'>WatiN Patterns #1: No Browser Left Behind</a></li>
<li><a href='http://www.richardlawrence.info/2009/01/24/another-look-at-watin/' rel='bookmark' title='Permanent Link: Another Look at WatiN'>Another Look at WatiN</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>After a long hiatus, I&#8217;m resuming the WatiN Patterns series. <a href="/2009/02/04/watin-patterns-1-no-browser-left-behind/">Pattern #1</a> covered why and how your tests should clean up after themselves. <a href="/2009/02/11/watin-patterns-2-one-assertion-and-a-name-to-match/">Pattern #2</a> covered how you should name your tests and why they should only assert one thing.</p>
<p>Pattern #3 is about keeping your tests maintainable by specifying just enough in your element selectors.</p>
<p><span id="more-202"></span></p>
<p>If you&#8217;re using WatiN, you&#8217;re probably also using ASP.NET Web Forms, which means your controls get IDs like this: ctl1001_Content_Content_txtUsername. Though you gave your username text box the ID &#8220;txtUsername&#8221;, ASP.NET prepends the IDs of each of the container controls to your text box&#8217;s ID in the HTML that goes to the browser. This is good for preventing name collisions between controls in different user controls on the same page. But it can lead you to write fragile tests. Consider this 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 />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #008000;">&#91;</span>Test<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> ShouldAuthenticateUsersSuccessfully<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>IE ie <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> IE<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">GoTo</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://mytestapp/&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">TextField</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ctl1001_Content_Content_txtUsername&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TypeText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;richard&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">TextField</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ctl1001_Content_Content_txtPassword&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TypeText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;password&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">Button</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ctl1001_Content_Content_btnLogin&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Click</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>ie<span style="color: #008000;">.</span><span style="color: #0000FF;">ContainsText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Welcome, Richard!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Suppose someone moves the login widgets outside one of those nested &#8220;Content&#8221; controls. Now our test fails. Did login stop working? Probably not. But, thanks to ASP.NET&#8217;s &#8220;helpful&#8221; ID scheme, we can no longer find the login widgets&mdash;their IDs have changed. We could update the test to the new IDs:</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 />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #008000;">&#91;</span>Test<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> ShouldAuthenticateUsersSuccessfully<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>IE ie <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> IE<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">GoTo</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://mytestapp/&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">TextField</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ctl1001_Content_txtUsername&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TypeText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;richard&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">TextField</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ctl1001_Content_txtPassword&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TypeText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;password&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">Button</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ctl1001_Content_btnLogin&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Click</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>ie<span style="color: #008000;">.</span><span style="color: #0000FF;">ContainsText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Welcome, Richard!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Or we could solve the root problem of fragile tests:</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 />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #008000;">&#91;</span>Test<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> ShouldAuthenticateUsersSuccessfully<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>IE ie <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> IE<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">GoTo</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://mytestapp/&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">TextField</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Regex<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;txtUsername$&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TypeText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;richard&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">TextField</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Regex<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;txtPassword$&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TypeText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;password&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">Button</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Regex<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;btnLogin$&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Click</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>ie<span style="color: #008000;">.</span><span style="color: #0000FF;">ContainsText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Welcome, Richard!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>WatiN accommodates regular expressions instead of strings for IDs. Now we&#8217;ve specified, &#8220;a text field with an ID ending in txtUsername&#8221; (note the ending dollar sign), instead of, &#8220;a text field with exactly the ID ctl1001_Content_Content_txtUsername.&#8221; Much more flexible.</p>
<p>To keep your tests from being fragile, <strong>when selecting elements on the page, use the least specific method and value necessary to find the element you want.</strong></p>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/02/11/watin-patterns-2-one-assertion-and-a-name-to-match/' rel='bookmark' title='Permanent Link: WatiN Patterns #2: One Assertion and a Name to Match'>WatiN Patterns #2: One Assertion and a Name to Match</a></li>
<li><a href='http://www.richardlawrence.info/2009/02/04/watin-patterns-1-no-browser-left-behind/' rel='bookmark' title='Permanent Link: WatiN Patterns #1: No Browser Left Behind'>WatiN Patterns #1: No Browser Left Behind</a></li>
<li><a href='http://www.richardlawrence.info/2009/01/24/another-look-at-watin/' rel='bookmark' title='Permanent Link: Another Look at WatiN'>Another Look at WatiN</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2009/10/30/watin-patterns-3-dont-over-specify/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Cuke4Nuke: Cucumber for .NET Teams</title>
		<link>http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/</link>
		<comments>http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 00:16:38 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[ATDD]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Cuke4Nuke]]></category>
		<category><![CDATA[Product Owner]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=174</guid>
		<description><![CDATA[Update: If you&#8217;ve just landed here, you could get the impression from this post that Cuke4Nuke doesn&#8217;t exist yet. It does. Check out this screencast showing what you can do with it as of early December 2009. If you’ve read this blog for a while or talked with me about functional test tools, you’ve heard [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/01/19/web-testing-for-net-teams-watin-or-watir/' rel='bookmark' title='Permanent Link: Web Testing for .NET Teams: WatiN or Watir?'>Web Testing for .NET Teams: WatiN or Watir?</a></li>
<li><a href='http://www.richardlawrence.info/2009/02/11/watin-patterns-2-one-assertion-and-a-name-to-match/' rel='bookmark' title='Permanent Link: WatiN Patterns #2: One Assertion and a Name to Match'>WatiN Patterns #2: One Assertion and a Name to Match</a></li>
<li><a href='http://www.richardlawrence.info/2008/11/13/a-common-but-bad-idea/' rel='bookmark' title='Permanent Link: A Common, but Bad, Idea'>A Common, but Bad, Idea</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p><strong>Update: If you&#8217;ve just landed here, you could get the impression from this post that Cuke4Nuke doesn&#8217;t exist yet. It does. Check out <a href="/2009/12/03/screencast-testing-web-applications-in-net-with-cuke4nuke-and-watin/">this screencast</a> showing what you can do with it as of early December 2009.</strong></p>
<p>If you’ve read this blog for a while or talked with me about functional test tools, you’ve heard me talk about <a href="http://cukes.info/">Cucumber</a>. It’s my favorite ATDD tool because it’s so good at mapping stories and acceptance criteria to automated functional tests. Product Owners and BAs write acceptance criteria in natural language. Developers and testers unobtrusively automate tests for them. Anyone on the team can run the tests and see the current state of the system.</p>
<p>Here’s a simple example:</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 /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Feature: Google search<br />
&nbsp; &nbsp; In order to find things on the web<br />
&nbsp; &nbsp; As a user<br />
&nbsp; &nbsp; I want to search for web pages containing specific text<br />
<br />
&nbsp; &nbsp; Scenario: Load search page<br />
&nbsp; &nbsp; &nbsp; &nbsp; When I go to the search page<br />
&nbsp; &nbsp; &nbsp; &nbsp; Then I should be on the search page<br />
<br />
&nbsp; &nbsp; Scenario: Search<br />
&nbsp; &nbsp; &nbsp; &nbsp; Given I'm on the search page<br />
&nbsp; &nbsp; &nbsp; &nbsp; When I search for &quot;richard lawrence&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Then I should see &quot;www.richardlawrence.info&quot; in the results</div></td></tr></tbody></table></div>
<p>This reads almost exactly as I teach Product Owners to specify acceptance criteria. But it’s not just text. It’s a potentially automated test.</p>
<p>A developer or tester can come along and automate this test like so in Ruby:</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 /></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:#008000; font-style:italic;"># assuming @google is an instance of a test DSL that wraps Watir, Selenium, etc.</span><br />
<br />
<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> <span style="color:#996600;">&quot;(.*)&quot;</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>query<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; <span style="color:#0066ff; font-weight:bold;">@google</span>.<span style="color:#9900CC;">search_for</span> query<br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">Then</span> <span style="color:#006600; font-weight:bold;">/</span>^I should see <span style="color:#996600;">&quot;(.*)&quot;</span> <span style="color:#9966CC; font-weight:bold;">in</span> the results$<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>expected_text<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; assert <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#0066ff; font-weight:bold;">@google</span>.<span style="color:#9900CC;">results_contain</span>? expected_text <span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#008000; font-style:italic;"># etc...</span></div></td></tr></tbody></table></div>
<p>Each of the Given/When/Then calls is a step definition. When there’s a matching line in a Cucumber test, the step definition gets executed.</p>
<p>Recently, support was added for step definitions in Java via a project called Cuke4Duke:</p>
<div class="codecolorer-container java 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 /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">@When<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;I search for <span style="color: #000099; font-weight: bold;">\&quot;</span>(*)<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> search<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> query<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; google.<span style="color: #006633;">searchFor</span><span style="color: #009900;">&#40;</span>query<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
@Then<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;I should see <span style="color: #000099; font-weight: bold;">\&quot;</span>(*)<span style="color: #000099; font-weight: bold;">\&quot;</span> in the results&quot;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> checkResults<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> expectedUrl<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; assertThat<span style="color: #009900;">&#40;</span>google.<span style="color: #006633;">containsResult</span><span style="color: #009900;">&#40;</span>expectedUrl<span style="color: #009900;">&#41;</span>, is<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Now, a Java team can use Cucumber without ever writing a line of Ruby.</p>
<p>Unfortunately, there’s nothing like this for .NET teams. Until now (or soon, anyway)…</p>
<h2>AA-FTT and the Birth of Cuke4Nuke</h2>
<p>Last month, I attended the Agile Alliance Functional Test Tool conference (AA-FTT for short). AA-FTT is an open space conference. I came with one goal: to get together with other people who want Cucumber for .NET and start making it happen. I wasn’t sure anyone else would be interested, so I was thrilled with the reaction.</p>
<p><a href="http://twitpic.com/he15c" title="Photo 2 of 4 from #aaftt in Chicago at the pre-conference wor... on Twitpic"><img src="http://twitpic.com/show/large/he15c.jpg" alt="Photo 2 of 4 from #aaftt in Chicago at the pre-conference wor... on Twitpic"></a></p>
<p>Aslak Hellesøy introduced Cucumber for those in the group who hadn’t used it and then talked through the multiple language support he’d recently added to the tool. Then, we discussed ways to build .NET support. The obvious solution was to use IronRuby and Cucumber’s language support to handle C# step definitions. <a href="http://blog.mattwynne.net/2009/09/10/the-agile-alliance-functional-testing-tools-workshop/">Matt Wynne</a> downloaded the latest IronRuby and installed Cucumber on it. He kicked off a simple Cucumber example, and we waited. And waited. Some two minutes later, we had results from tests that take less than two seconds to run under the standard Ruby interpreter. In a process that values frequent, fast test runs, IronRuby was a non-starter. (If you want to try Cucumber under IronRuby, <a href="http://blog.thomaslundstrom.com/2009/08/on-running-cucumber-under-ironruby-09.html">here are some instructions</a>.)</p>
<p>So we discussed other options and settled on using a simple wire protocol for Cucumber to communicate to .NET out-of-process, similar to Slim in FitNesse. And here’s the best part: we started building it. Matt and I paired right there to start fleshing out the wire protocol (with Cucumber tests, naturally). Later in the week at Agile 2009, Matt and Aslak paired to build the Ruby side of the wire protocol, and Matt and I tackled the first bits of the .NET side. Last week, I got the skeleton of the .NET side working and up on GitHub. You can define simple steps in C#. Cucumber can ask the .NET wire server to tell it about the steps it has and to invoke them and return the pass/fail results.</p>
<p>About a week ago, Aslak <a href="http://groups.google.com/group/cukes/browse_thread/thread/27674320d7725feb">announced the project on the Cucumber mailing list and recruited more contributors</a>. Declan Whelan, Scott Ford, Åsmund Eldhuset, Anders Hammervold, Chris Kooken, and Steve Eley have already stepped up with ideas and code.</p>
<h2 id="gettinginvoled">Getting Involed</h2>
<p>How can you get involved? I’m glad you asked.</p>
<ol>
<li>Join <a href="http://groups.google.com/group/cukes">the mailing list</a>.</li>
<li>Fork <a href="http://github.com/richardlawrence/Cuke4Nuke">the GitHub repository</a> and work on one of the features in <a href="http://github.com/richardlawrence/Cuke4Nuke/issues">the backlog</a>.</li>
<li>Post a message to the mailing list to let us know what you’re working on. I’ll tag the ticket in the backlog with your GitHub username so we don’t duplicate effort. Prefix your message subject with [Cuke4Nuke].</li>
<li>Comment on tickets in the backlog.</li>
<li>Try using Cuke4Nuke as we develop it and give us feedback via the mailing list.</li>
<li>Shout encouragements in the comments here and on Twitter to let us know you care, even if you can’t contribute.</li>
</ol>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/01/19/web-testing-for-net-teams-watin-or-watir/' rel='bookmark' title='Permanent Link: Web Testing for .NET Teams: WatiN or Watir?'>Web Testing for .NET Teams: WatiN or Watir?</a></li>
<li><a href='http://www.richardlawrence.info/2009/02/11/watin-patterns-2-one-assertion-and-a-name-to-match/' rel='bookmark' title='Permanent Link: WatiN Patterns #2: One Assertion and a Name to Match'>WatiN Patterns #2: One Assertion and a Name to Match</a></li>
<li><a href='http://www.richardlawrence.info/2008/11/13/a-common-but-bad-idea/' rel='bookmark' title='Permanent Link: A Common, but Bad, Idea'>A Common, but Bad, Idea</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2009/09/19/cuke4nuke-cucumber-for-net-teams/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>WatiN Patterns #2: One Assertion and a Name to Match</title>
		<link>http://www.richardlawrence.info/2009/02/11/watin-patterns-2-one-assertion-and-a-name-to-match/</link>
		<comments>http://www.richardlawrence.info/2009/02/11/watin-patterns-2-one-assertion-and-a-name-to-match/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 23:46:19 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[WatiN]]></category>
		<category><![CDATA[WatiN Patterns]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=146</guid>
		<description><![CDATA[One way to keep your WatiN tests maintainable is to keep them small and focused. WatiN Pattern #2, then, is a way to do just that. Your tests should assert one thing. Just one. And the name of the test should describe whatever it is you&#8217;re asserting. Looking at our example from last time, we [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/02/04/watin-patterns-1-no-browser-left-behind/' rel='bookmark' title='Permanent Link: WatiN Patterns #1: No Browser Left Behind'>WatiN Patterns #1: No Browser Left Behind</a></li>
<li><a href='http://www.richardlawrence.info/2009/01/24/another-look-at-watin/' rel='bookmark' title='Permanent Link: Another Look at WatiN'>Another Look at WatiN</a></li>
<li><a href='http://www.richardlawrence.info/2009/01/19/web-testing-for-net-teams-watin-or-watir/' rel='bookmark' title='Permanent Link: Web Testing for .NET Teams: WatiN or Watir?'>Web Testing for .NET Teams: WatiN or Watir?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>One way to keep your WatiN tests maintainable is to keep them small and focused. WatiN Pattern #2, then, is a way to do just that.</p>
<p><span id="more-146"></span></p>
<p>Your <strong>tests should assert one thing</strong>. Just one. And <strong>the name of the test should describe whatever it is you&#8217;re asserting</strong>. Looking at our example from <a href="/2009/02/04/watin-patterns-1-no-browser-left-behind/">last time</a>, we see that we&#8217;ve got the one assertion part right, but the name doesn&#8217;t match.</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 />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#91;</span>TestMethod<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SearchPageTest<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>IE ie <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> IE<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">GoTo</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://www.google.com/&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">TextField</span><span style="color: #008000;">&#40;</span>Find<span style="color: #008000;">.</span><span style="color: #0000FF;">ByName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;q&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TypeText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Richard Lawrence&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">Button</span><span style="color: #008000;">&#40;</span>Find<span style="color: #008000;">.</span><span style="color: #0000FF;">ByName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;btnG&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Click</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>ie<span style="color: #008000;">.</span><span style="color: #0000FF;">ContainsText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;www.richardlawrence.info&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>In a nod to the <a href="http://dannorth.net/introducing-bdd">BDD approach</a> (more BDD to show up in future patterns), I like to <strong>name the test class for the thing we&#8217;re testing and use test names starting with &#8220;Should&#8221; that specify what the thing we&#8217;re testing ought to do</strong>. So, we could change our example to 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 />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<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: #008080; font-style: italic;">// using statements, namespace declaration, etc.</span><br />
<span style="color: #008080; font-style: italic;">// ...</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#91;</span>TestClass<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> GoogleSearchPage<br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// ...</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#91;</span>TestMethod<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> ShouldReturnSearchResultsSuccessfully<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>IE ie <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> IE<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">GoTo</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://www.google.com/&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">TextField</span><span style="color: #008000;">&#40;</span>Find<span style="color: #008000;">.</span><span style="color: #0000FF;">ByName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;q&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TypeText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Richard Lawrence&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">Button</span><span style="color: #008000;">&#40;</span>Find<span style="color: #008000;">.</span><span style="color: #0000FF;">ByName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;btnG&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Click</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>ie<span style="color: #008000;">.</span><span style="color: #0000FF;">ContainsText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;www.richardlawrence.info&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Now we have one assertion, and our test name indicates that it&#8217;s asserting that the Google search page should return search results successfully. <strong>If that test fails, we know what&#8217;s gone wrong.</strong></p>
<p>It&#8217;s not yet transparent that the assertion on line 17 does what the test name indicates, but we&#8217;ll deal with that in future patterns.</p>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/02/04/watin-patterns-1-no-browser-left-behind/' rel='bookmark' title='Permanent Link: WatiN Patterns #1: No Browser Left Behind'>WatiN Patterns #1: No Browser Left Behind</a></li>
<li><a href='http://www.richardlawrence.info/2009/01/24/another-look-at-watin/' rel='bookmark' title='Permanent Link: Another Look at WatiN'>Another Look at WatiN</a></li>
<li><a href='http://www.richardlawrence.info/2009/01/19/web-testing-for-net-teams-watin-or-watir/' rel='bookmark' title='Permanent Link: Web Testing for .NET Teams: WatiN or Watir?'>Web Testing for .NET Teams: WatiN or Watir?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2009/02/11/watin-patterns-2-one-assertion-and-a-name-to-match/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WatiN Patterns #1: No Browser Left Behind</title>
		<link>http://www.richardlawrence.info/2009/02/04/watin-patterns-1-no-browser-left-behind/</link>
		<comments>http://www.richardlawrence.info/2009/02/04/watin-patterns-1-no-browser-left-behind/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 23:35:44 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[WatiN]]></category>
		<category><![CDATA[WatiN Patterns]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=119</guid>
		<description><![CDATA[In my previous posts on WatiN, I lamented the shortage of online documentation and resolved to do something about it by documenting the patterns I&#8217;ve found for good WatiN tests. This is the first in a series in which I&#8217;ll take an example of the typical beginner WatiN test I see and refactor it to [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/01/24/another-look-at-watin/' rel='bookmark' title='Permanent Link: Another Look at WatiN'>Another Look at WatiN</a></li>
<li><a href='http://www.richardlawrence.info/2009/01/19/web-testing-for-net-teams-watin-or-watir/' rel='bookmark' title='Permanent Link: Web Testing for .NET Teams: WatiN or Watir?'>Web Testing for .NET Teams: WatiN or Watir?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>In my <a href="/2009/01/19/web-testing-for-net-teams-watin-or-watir/" title="Web Testing for .NET Teams: WatiN or Watir?">previous</a> <a href="/2009/01/24/another-look-at-watin/" title="Another Look at WatiN">posts</a> on WatiN, I lamented the shortage of online documentation and resolved to do something about it by documenting the patterns I&#8217;ve found for good WatiN tests. This is the first in a <a href="/tag/watin-patterns/" title="All WatiN Patterns posts">series</a> in which I&#8217;ll take an example of the typical beginner WatiN test I see and refactor it to use the patterns I recommend.</p>
<p>Consider this test:</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 />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#91;</span>TestMethod<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SearchPageTest<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IE ie <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> IE<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">GoTo</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://www.google.com/&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">TextField</span><span style="color: #008000;">&#40;</span>Find<span style="color: #008000;">.</span><span style="color: #0000FF;">ByName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;q&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TypeText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Richard Lawrence&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">Button</span><span style="color: #008000;">&#40;</span>Find<span style="color: #008000;">.</span><span style="color: #0000FF;">ByName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;btnG&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Click</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>ie<span style="color: #008000;">.</span><span style="color: #0000FF;">ContainsText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;www.richardlawrence.info&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">Close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>It has a few problems, but I want to highlight one in this post: <strong>This test doesn&#8217;t properly clean up after itself.</strong> If the code on lines 66-70 throws an exception or if the assertion fails, line 71 will never be executed. When you&#8217;re testing on your own machine, this can be annoying&mdash;you have to close the IE window manually. But if the test runs unattended (e.g. as part of continuous integration) it can be much more than annoying.</p>
<p><span id="more-119"></span></p>
<p>I&#8217;ve sometimes seen this attempt to work around the problem:</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 />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#91;</span>TestMethod<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SearchPageTest<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IE ie <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> IE<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">GoTo</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://www.google.com/&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">TextField</span><span style="color: #008000;">&#40;</span>Find<span style="color: #008000;">.</span><span style="color: #0000FF;">ByName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;q&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TypeText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Richard Lawrence&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">Button</span><span style="color: #008000;">&#40;</span>Find<span style="color: #008000;">.</span><span style="color: #0000FF;">ByName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;btnG&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Click</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">bool</span> resultsFound <span style="color: #008000;">=</span> ie<span style="color: #008000;">.</span><span style="color: #0000FF;">ContainsText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;www.richardlawrence.info&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">Close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>resultsFound<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Introducing a local boolean to indicate success and closing the browser before the assertion ensures that the browser gets closed whether the assertion fails or succeeds. However, it won&#8217;t necessarily close the browser in case of an exception.</p>
<p>Fortunately, WatiN.Core.IE implements IDisposable, so you can do 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 />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#91;</span>TestMethod<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SearchPageTest<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>IE ie <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> IE<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">GoTo</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://www.google.com/&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">TextField</span><span style="color: #008000;">&#40;</span>Find<span style="color: #008000;">.</span><span style="color: #0000FF;">ByName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;q&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">TypeText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Richard Lawrence&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">Button</span><span style="color: #008000;">&#40;</span>Find<span style="color: #008000;">.</span><span style="color: #0000FF;">ByName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;btnG&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Click</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Assert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsTrue</span><span style="color: #008000;">&#40;</span>ie<span style="color: #008000;">.</span><span style="color: #0000FF;">ContainsText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;www.richardlawrence.info&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>In case you&#8217;re not familar with the &#8220;using&#8221; statement, it&#8217;s a shortcut for 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 />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; IE ie<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">try</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ie <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> IE<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// whatever you're going to do with ie</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">finally</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>ie <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">Dispose</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>At the end of the using block (or when an exception is thrown) ie.Dispose() is called, which closes the browser window.</p>
<p><strong>Use this pattern in your WatiN tests to ensure that your tests clean up after themselves and leave no browser window behind.</strong></p>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/01/24/another-look-at-watin/' rel='bookmark' title='Permanent Link: Another Look at WatiN'>Another Look at WatiN</a></li>
<li><a href='http://www.richardlawrence.info/2009/01/19/web-testing-for-net-teams-watin-or-watir/' rel='bookmark' title='Permanent Link: Web Testing for .NET Teams: WatiN or Watir?'>Web Testing for .NET Teams: WatiN or Watir?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2009/02/04/watin-patterns-1-no-browser-left-behind/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Another Look at WatiN</title>
		<link>http://www.richardlawrence.info/2009/01/24/another-look-at-watin/</link>
		<comments>http://www.richardlawrence.info/2009/01/24/another-look-at-watin/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 16:29:50 +0000</pubDate>
		<dc:creator>Richard Lawrence</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[Agile 2009]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[WatiN]]></category>
		<category><![CDATA[Watir]]></category>

		<guid isPermaLink="false">http://www.richardlawrence.info/?p=115</guid>
		<description><![CDATA[At my current client, we&#8217;ve decided to use WatiN, largely for the C# vs. Ruby reason I discussed earlier this week. After spending a week working with WatiN (following a year of rarely using it), I&#8217;m impressed. Ruby and the active Watir community still have their advantages. But WatiN has really come into its own [...]


Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/01/19/web-testing-for-net-teams-watin-or-watir/' rel='bookmark' title='Permanent Link: Web Testing for .NET Teams: WatiN or Watir?'>Web Testing for .NET Teams: WatiN or Watir?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>At my current client, we&#8217;ve decided to use <a href="http://watin.sourceforge.net/">WatiN</a>, largely for the C# vs. Ruby reason I <a href="/2009/01/19/web-testing-for-net-teams-watin-or-watir/">discussed earlier this week</a>. After spending a week working with WatiN (following a year of rarely using it), I&#8217;m impressed. Ruby and the active Watir community still have their advantages. But WatiN has really come into its own with C# 3.0 features like lambdas. I&#8217;m pleased with the test code we&#8217;re producing in terms of readability, speed, flexibility, and maintainability. I&#8217;ve proposed an <a href="http://agile2009.agilealliance.org/">Agile 2009</a> tutorial <a title="Please log in and add comments on my session proposal." href="http://agile2009.agilealliance.org/node/505">session</a> on the patterns I&#8217;m using to get those results, and I&#8217;ll post more on that topic here soon. (Which will hopefully help with one of WatiN&#8217;s shortcomings—documentation.)</p>


<p>Related posts:<ol><li><a href='http://www.richardlawrence.info/2009/01/19/web-testing-for-net-teams-watin-or-watir/' rel='bookmark' title='Permanent Link: Web Testing for .NET Teams: WatiN or Watir?'>Web Testing for .NET Teams: WatiN or Watir?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlawrence.info/2009/01/24/another-look-at-watin/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

