<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>test-driven-development &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/test-driven-development/</link>
	<description>Feed of posts on WordPress.com tagged "test-driven-development"</description>
	<pubDate>Sun, 27 Dec 2009 18:46:54 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Python TDD Example]]></title>
<link>http://ajlopez.wordpress.com/2009/12/23/python-tdd-example/</link>
<pubDate>Wed, 23 Dec 2009 11:05:44 +0000</pubDate>
<dc:creator>ajlopez</dc:creator>
<guid>http://ajlopez.wordpress.com/2009/12/23/python-tdd-example/</guid>
<description><![CDATA[One of the practices I try to “sell” to anybody involved in software development, is the practice of]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>One of the practices I try to “sell” to anybody involved in software development, is the practice of Test-Driven Development. Once you have practice TDD, you never go back. It is a practice with so much reward and joy, I feel uneasy when I wrote real software without using it.</p>
<p>Thanks to a tweet by @jjfalcon, I discovered this example, in Youtube, by user <a href="http://www.youtube.com/user/objarni" target="_blank">objarni</a>. He is using Ubuntu, programming in Python, and using pyTDDemon to see inmediatly the results of test.</p>
<p>Note the red-green-refactor cycle, the minimal code that is added in each tests (only to have green in test, including cheating in return values), refactoring the test if there are duplicated code, microdesign decisions, etc… Nice work!</p>
<p><span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/sD6qzJNQEpE&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' /><param name='allowfullscreen' value='true' /><param name='wmode' value='transparent' /><embed src='http://www.youtube.com/v/sD6qzJNQEpE&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='transparent'></embed></object></span></p>
<p><span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/QTrGVf39Unk&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' /><param name='allowfullscreen' value='true' /><param name='wmode' value='transparent' /><embed src='http://www.youtube.com/v/QTrGVf39Unk&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='transparent'></embed></object></span></p>
<p><span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/ATsCl00OyDU&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' /><param name='allowfullscreen' value='true' /><param name='wmode' value='transparent' /><embed src='http://www.youtube.com/v/ATsCl00OyDU&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='transparent'></embed></object></span></p>
<p><span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/YPDjWgYor0Y&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' /><param name='allowfullscreen' value='true' /><param name='wmode' value='transparent' /><embed src='http://www.youtube.com/v/YPDjWgYor0Y&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='transparent'></embed></object></span></p>
<p>I tagged more videos about TDD, in my delicious:</p>
<p><a title="http://delicious.com/ajlopez/tdd+video" href="http://delicious.com/ajlopez/tdd+video">http://delicious.com/ajlopez/tdd+video</a></p>
<p>All about TDD</p>
<p><a href="http://delicious.com/ajlopez/tdd">http://delicious.com/ajlopez/tdd</a></p>
<p>Angel “Java” Lopez   <br /><a href="http://www.ajlopez.com">http://www.ajlopez.com</a>    <br /><a href="http://twitter.com/ajlopez">http://twitter.com/ajlopez</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[NUnit and Configuration files]]></title>
<link>http://hanseh.wordpress.com/2009/12/14/nunit-and-configuration-files/</link>
<pubDate>Mon, 14 Dec 2009 06:10:25 +0000</pubDate>
<dc:creator>hanseh</dc:creator>
<guid>http://hanseh.wordpress.com/2009/12/14/nunit-and-configuration-files/</guid>
<description><![CDATA[There are lots of testing frameworks that are present in the internet now a days and one of them is ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><!-- 		@page { margin: 2cm } 		P { margin-bottom: 0.21cm } --> There are lots of testing frameworks that are present in the internet now a days and one of them is NUnit. It is basically easy to use and is a very useful tool. I&#8217;ve tried to integrate it in one of our projects in replacement for the Microsoft testing framework. Everything went well and a few test fixtures was made. The problem occurred when we tried to perform integration testing where in we need to access the database to perform model testing. This is prior in using dbunit for model testing.</p>
<p>The issue was, the connection cannot be created. To add more insult to the injury, the error didn&#8217;t came that easy to be figured out. We need to dig the stack trace to figure out what went wrong. It is a minor issue yet it took a bit of our time figuring it out. And after a few hours of testing, here&#8217;s what we found out.</p>
<p>NUnit does not read the project&#8217;s config file(<em>web.config</em>), as opposed by .net built-in test enviroment which uses the actual config file.  NUnit has its own configuration file which can be either NUnit-console.exe.config or NUnit-gui.exe.config. Yet this configuration files does not act as configuration files for the project but rather config files for the NUnit itself.</p>
<p>When NUnit runs your test, it creates a separate AppDomain in order to give them a different set of directories for finding assemblies and a different configuration file from NUnit itself. NUnit tells the .net framework the name of the configuration file to use. You can refer to the following step  for setting the project configuration file path.</p>
<ol>
<li>Create a new NUnit project for 	your application.</li>
<li>Click Project tab then Edit&#8230;</li>
<li>A new window will appear, set the 	Configuration file name on the config file name textbox.</li>
<li>Save and close the window and run 	your test.</li>
<li>Create the config file on the bin 	folder and set your config initialization.</li>
</ol>
<p>The above process works if you create a specific NUnit project, but if you directly load a .net project assemly, such as myapp.dll(usually located in the bin folder), the config file will automatically be named myapp.dll.config.  You can now copy your myapp.dll and rename it ti myapp.dll.config and set the necessary values needed by the test application.</p>
<p>Lastly, If you use NUnit’s Visual Studio support to load a Visual Studio project or solution, such as mytests.csproj or mytests.sln, the config file must be named mytests.config. In all of these cases, the config file must be in the same directory as the assembly or project that you are loading.</p>
<p>If you aren&#8217;t sure whether your config file is being used, a good trick is to put a special setting in it and write a test to see if that setting can be retrieved. For example,</p>
<p><code><br />
<span style="color:#3366ff;">[Test]</span><br />
<span style="color:#3366ff;">public void</span> CheckConfigFile()<br />
<span style="color:#3366ff;">{</span><br />
<span style="color:#3366ff;">Assert</span>.<span style="color:#3366ff;">AreEqual</span>( <span style="color:#00ff00;">"checkconfig"</span>, <span style="color:#3366ff;">ConfigurationSettings</span>.<span style="color:#3366ff;">AppSettings</span>[<span style="color:#00ff00;">"configCheck"</span>] );<br />
<span style="color:#3366ff;">}</span></code></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Writing an Eclipse Plug-in (Part 14): Common Navigator: Refactoring the Children]]></title>
<link>http://cvalcarcel.wordpress.com/2009/12/13/writing-an-eclipse-plug-in-part-14-common-navigator-refactoring-the-children/</link>
<pubDate>Mon, 14 Dec 2009 03:01:21 +0000</pubDate>
<dc:creator>cvalcarcel</dc:creator>
<guid>http://cvalcarcel.wordpress.com/2009/12/13/writing-an-eclipse-plug-in-part-14-common-navigator-refactoring-the-children/</guid>
<description><![CDATA[Well, it is late on a Sunday afternoon and I really want to refactor the children of the navigator. ]]></description>
<content:encoded><![CDATA[Well, it is late on a Sunday afternoon and I really want to refactor the children of the navigator. ]]></content:encoded>
</item>
<item>
<title><![CDATA[And Now By Popular Demand: jWebUnit]]></title>
<link>http://cvalcarcel.wordpress.com/2009/12/13/and-now-by-popular-demand-jwebunit/</link>
<pubDate>Sun, 13 Dec 2009 20:55:18 +0000</pubDate>
<dc:creator>cvalcarcel</dc:creator>
<guid>http://cvalcarcel.wordpress.com/2009/12/13/and-now-by-popular-demand-jwebunit/</guid>
<description><![CDATA[In the land of TDD things start pretty raw (plain vanilla JUnit) and slowly work their way out. Whil]]></description>
<content:encoded><![CDATA[In the land of TDD things start pretty raw (plain vanilla JUnit) and slowly work their way out. Whil]]></content:encoded>
</item>
<item>
<title><![CDATA[Note to Paul Chaplin: on TDD frameworks]]></title>
<link>http://dagobart.wordpress.com/2009/12/12/note-to-paul-chaplin-on-tdd-frameworks/</link>
<pubDate>Sat, 12 Dec 2009 12:45:58 +0000</pubDate>
<dc:creator>dagobart</dc:creator>
<guid>http://dagobart.wordpress.com/2009/12/12/note-to-paul-chaplin-on-tdd-frameworks/</guid>
<description><![CDATA[Paul, I&#8217;ve been searching for a TDD framework in C, and your post cracked the issue for me, ma]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Paul,</p>
<p>I&#8217;ve been searching for a TDD framework in C, and <a href="http://www.paulchaplin.com/blog/behaviour-driven-development-bdd-frameworks">your post</a> cracked the issue for me, made me look for/use the right search terms.</p>
<p>In the meantime, I found something that extends your list a little. Because of your helpful hints, I want to give back (Unfortunately I didn&#8217;t try to get over hurdles (log in?) to post a comment on your blog, hence I do it here on my own):</p>
<ul>
<li><a href="http://cunit.sourceforge.net/">CUnit</a> seems to be kind of &#8216;that&#8217; C TDD framework</li>
<li><a href="http://en.wikipedia.org/wiki/XUnit">Wikipedia/XUnit</a> looks like a good anchor point from where to get the search for any language&#8217;s TDD framework really started</li>
<li>and finally, <a href="http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks">Wikipedia/List of unit testing frameworks</a> looks like a good survey on at least C TDD frameworks.</li>
</ul>
<p>(I hope, this is a good contribution of mine to your posting.)</p>
<p>Best,<br />
dagobart</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Test Driven Development with a Widescreen Monitor]]></title>
<link>http://devblog.point2.com/2009/12/09/test-driven-development-with-a-widescreen-monitor/</link>
<pubDate>Wed, 09 Dec 2009 14:34:39 +0000</pubDate>
<dc:creator>Sean Reilly</dc:creator>
<guid>http://devblog.point2.com/2009/12/09/test-driven-development-with-a-widescreen-monitor/</guid>
<description><![CDATA[My Point2 workstation recently received a monitor upgrade; the old pair had had served me faithfully]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>My Point2 workstation recently received a monitor upgrade; the old pair had had served me faithfully for many years, but they were worn out. So I am now the proud user of a pair of shiny new widescreen monitors.</p>
<p>The new monitors are much nicer than the previous monitors, and they are also a much higher resolution (1920 x 1080 vs 960 x 1280). Using them is a very enjoyable experience, but at first it seemed like the widescreen aspect ratio was wasting a lot of horizontal space:</p>
<div id="attachment_1202" class="wp-caption aligncenter" style="width: 480px"><a href="http://point2blog.wordpress.com/files/2009/12/widescreen-tdd-before.png"><img class="size-full wp-image-1202" title="Before: my widescreen monitor with a single file open" src="http://point2blog.wordpress.com/files/2009/12/widescreen-tdd-before.png" alt="Before: my widescreen monitor with a single file open" width="470" height="264" /></a><p class="wp-caption-text">Before: my widescreen monitor with a single file open</p></div>
<p>Then a few days ago, in the middle of a pairing session, I discovered IntelliJ&#8217;s split screen feature. In my opinion, the combination of a wide screen monitor and split screen is a killer feature for TDD. If you assign your test code in one pane, and your production code to another pane, you can see your test and production code <strong><em>at the same time</em></strong>:</p>
<div id="attachment_1203" class="wp-caption aligncenter" style="width: 480px"><a href="http://point2blog.wordpress.com/files/2009/12/widescreen-tdd-after.png"><img class="size-full wp-image-1203" title="After: my widescreen with two files open simultaneously" src="http://point2blog.wordpress.com/files/2009/12/widescreen-tdd-after.png" alt="" width="470" height="264" /></a><p class="wp-caption-text">After: my widescreen with two files open simultaneously</p></div>
<p>To activate split screen choose &#8220;Split Vertically&#8221; from the Window menu, or right click on a document tab and choose &#8220;Split Vertically&#8221;.</p>
<p>IntelliJ works very nicely with this split screen configuration; intentions, &#8220;Go To Declaration&#8221;, and refactoring shortcuts jump nicely to the appropriate screen. Being able to read test and production code at the same time without clicking a button is especially valuable when pairing, as each half of the pair can be reading a different file. One important caveat: this only works correctly if each file is only open in one pane, and IntelliJ doesn&#8217;t enforce that for you.</p>
<p>Some of you might wonder what the second monitor is used for, and the answer is pair programming. We pair program all the time at Point2, so I run the two monitors as mirrors. I&#8217;ve also added an extra keyboard and mouse, and the combination allows each member of the pair to see exactly what&#8217;s going without craning their necks or stretching. It&#8217;s a really nice feature for a pairing station.</p>
<div id="attachment_1204" class="wp-caption aligncenter" style="width: 480px"><a href="http://point2blog.wordpress.com/files/2009/12/pairing-station.jpg"><img class="size-full wp-image-1204" title="My &#34;Pairing Station&#34; - a pair friendly workstation" src="http://point2blog.wordpress.com/files/2009/12/pairing-station.jpg" alt="My &#34;Pairing Station&#34; - a pair friendly workstation" width="470" height="352" /></a><p class="wp-caption-text">My pair-friendly workstation. My keyboard and trackball are on the left, and the developer pairing with me has their own keyboard, mouse, and monitor on the right. Either of us can drive without any inconvenience.</p></div>
<p>By: <a href="http://devblog.point2.com/author/seanjreilly/" target="_blank">Sean Reilly</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Writing an Eclipse Plug-in (Part 13): Common Navigator: Adding Tests]]></title>
<link>http://cvalcarcel.wordpress.com/2009/12/08/writing-an-eclipse-plug-in-part-13-common-navigator-adding-tests/</link>
<pubDate>Tue, 08 Dec 2009 05:02:43 +0000</pubDate>
<dc:creator>cvalcarcel</dc:creator>
<guid>http://cvalcarcel.wordpress.com/2009/12/08/writing-an-eclipse-plug-in-part-13-common-navigator-adding-tests/</guid>
<description><![CDATA[And now it is time for the mundane. While I firmly believe in test-driven development I do not belie]]></description>
<content:encoded><![CDATA[And now it is time for the mundane. While I firmly believe in test-driven development I do not belie]]></content:encoded>
</item>
<item>
<title><![CDATA[Program Specification Through the Mechanism of Automated Tests]]></title>
<link>http://adammcraventech.wordpress.com/2009/12/07/program-specification-through-the-mechanism-of-automated-tests/</link>
<pubDate>Sun, 06 Dec 2009 16:04:04 +0000</pubDate>
<dc:creator>Adam Craven</dc:creator>
<guid>http://adammcraventech.wordpress.com/2009/12/07/program-specification-through-the-mechanism-of-automated-tests/</guid>
<description><![CDATA[My previous findings regarding the testing of public methods versus private methods opened the door ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>My previous findings regarding <a title="Showdown: Testing Private Methods Versus Public Methods" href="http://adammcraventech.wordpress.com/2009/12/06/showdown-testing-private-methods-versus-public-methods/" target="_blank">the testing of public methods versus private methods</a> opened the door to allow me to better understand that the mindset of a developer performing unit “testing” is different from the mindset of a developer “specifying program behaviour through the mechanism of automated test methods”. The difference is subtle but important.</p>
<p>In the concept and terminology of Behaviour-Driven Development, Design, Analysis and Programming, the resulting program code is simply an implementation of previously specified behaviours. Those said behaviours are initially defined at the business level via the process of requirements gathering and specification, and can be expressed in the business’s language as a set of scenarios and stories. These requirements can then be further analysed and broken down into logical and physical program specifications.</p>
<p>Regardless of whether a test-first approach to development is taken, by the end of the construction task, there should be a set of unit test cases (automatic and/or manual) that were successfully executed and that covers all of the logic specified in the program specification. In other words, by the end of the construction task, the developer has verified that the program behaves as specified.</p>
<p>Typically a program’s specification is written in a document somewhere which is divorced from the location of the actual code -  so great discipline and effort is required in order to keep the specification and code in synch over time. Depending on the company and financial constraints of the project, this may not be feasible.</p>
<p>However, what if we could remove this boundary between the document and the code?</p>
<p>Automated test cases serve a number of useful purposes, including:</p>
<blockquote><p>- Behaviour verification;</p>
<p>- Acting as a “safety net” for refactoring code;</p>
<p>- Regression testing;</p>
<p>- Professional evidence that one’s own code actually does what one has said it does; and</p>
<p>- Acting as sample code for other developers so they can see how to use one’s code.</p></blockquote>
<p>What if the automated test assets <em>were</em> the actual living program specification that is verified through the mechanism of test methods?</p>
<p>This concept has been recognised before, and the libraries JBehave, RSpec, NBehave and NSpec have been the result. While I honour the efforts that have gone into those libraries and the ground-breaking concepts, I do not necessarily like the usage of them.</p>
<p>In fact, all I want is to be able to express my specifications in my MSTest classes without the need for a different test runner or the need for another testing framework. In addition, I want other team members to easily grasp the concept and quickly up-skill without too much disruption.</p>
<p>While a DSL might be more ideal under these circumstances, I write my automated test assets in the C# language. Working within that constraint, I want to express the program specification in test code. With special note to the agreeable BDD concept that <a href="http://dannorth.net/introducing-bdd" target="_blank">“Test method names should be sentences”</a> I devised the following structure for expressing program specifications as automated test methods.</p>
<blockquote><p>namespace &#124;MyCompany&#124;.&#124;MyAssembly&#124;.BehaviourTests. &#124;MyClassUnderSpecification&#124;<strong>Spec</strong></p>
<p>{</p>
<p>public class &#124;MyPublicMethodUnderSpecification&#124;<strong>Spec</strong></p>
<p>{</p>
<p>[TestClass]</p>
<p>public class <strong>Scenario</strong>&#124;WithDescriptiveName&#124;</p>
<p>{</p>
<p>[TestMethod]</p>
<p>public void <strong>When</strong>&#124;MoreScenarioDetails&#124;<strong>Should</strong>&#124;Blah&#124;</p>
<p>{</p>
<p>// Test code here</p>
<p>}</p>
<p>[TestMethod]</p>
<p>public void <strong>When</strong>&#124;AnotherSubScenario&#124;<strong>Should</strong>&#124;Blah&#124;</p>
<p>{</p>
<p>// Test code here</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>}</p></blockquote>
<p>This structure allows for the naming of the public method that is under specification (the parent class name), a general scenario with a description of the context or given setup required (the nested MSTest class name), followed by the test method names which further narrow the scenario and provide descriptive details of the expected behaviour.</p>
<p>The test names look neat in the Test View in Visual Studio (when the Full Classname column is visible), and are readable just like their corresponding stories.</p>
<p>The full class name in this instance would look like:</p>
<p>&#124;MyCompany&#124;.&#124;MyAssembly&#124;.BehaviourTests. &#124;MyClassUnderSpecification&#124;Spec. &#124;MyPublicMethodUnderSpecification&#124;Spec +Scenario&#124;WithDescriptiveName&#124;</p>
<p>With automated spec/test assets/classes structured in this fashion, instead of developers performing unit “testing”, developers can instead embrace the mindset of “specifying program behaviour through the mechanism of automated test methods”. In turn, developers should be more focused on their tasks and it should also lead to higher quality code bases.</p>
<p>Oh, and I haven’t even mentioned how much easier it would be for a developer new to a project to learn and understand the code base by looking at the test view and reading all the scenarios that have been specified and coded…</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[FB4 and Unit Testing]]></title>
<link>http://michaelangela.wordpress.com/2009/12/02/fb4-and-unit-testing/</link>
<pubDate>Wed, 02 Dec 2009 09:35:30 +0000</pubDate>
<dc:creator>michaelangela</dc:creator>
<guid>http://michaelangela.wordpress.com/2009/12/02/fb4-and-unit-testing/</guid>
<description><![CDATA[This makes me want to use Flash Builder 4! Introduction to Unit Testing &#8211; Activetuts+ Unit tes]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>This makes me want to use Flash Builder 4!</p>
<p><a href="http://active.tutsplus.com/tutorials/workflow/introduction-to-unit-testing/">Introduction to Unit Testing &#8211; Activetuts+</a><br />
<blockquote>Unit testing is relatively new to ActionScript projects. Although FlexUnit has been around for a while it wasn&#8217;t intuitive to set up and there were a lot of inconsistencies with the documentation. Lucky for us, FlexUnit is now built into Flash Builder 4. Although the documentation is still sparse, this tutorial will be a good primer for setting up a Test Suite, going over several unit test examples and showing how to run/analyze them.</p></blockquote>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=4e2c276b-5446-8fdc-b65d-39366081fdfc" /></div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Links on app testing and functional testing]]></title>
<link>http://michaelangela.wordpress.com/2009/11/30/links-on-app-testing-and-functional-testing/</link>
<pubDate>Mon, 30 Nov 2009 14:18:53 +0000</pubDate>
<dc:creator>michaelangela</dc:creator>
<guid>http://michaelangela.wordpress.com/2009/11/30/links-on-app-testing-and-functional-testing/</guid>
<description><![CDATA[I just want these in one place for future reference, in no particular order except the order they ar]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I just want these in one place for future reference, in no particular order except the order they are open in tabs in Firefox at the moment&#8230;</p>
<p><a href="http://www.testinggeek.com/index.php/testing-tools/test-execution/166-selenium-ide-rc-workshop-tutorial">Software Testing Geek -Software Testing &#8211; Selenium IDE, RC Tutorial &#38; Workshop</a></p>
<p><a href="http://watir.com/examples/">Examples « Watir</a></p>
<p><a href="http://wiki.github.com/bard/mozrepl">Home &#8211; mozrepl &#8211; GitHub</a></p>
<p><a href="http://www.testinggeek.com/index.php/testing-tools/test-execution/175-twill-web-automation-tool-in-python">Software Testing Geek -Twill &#8211; Simple Web Automation Tool in Python</a></p>
<p><a href="http://www.3hv.co.uk/blog/2009/01/16/cucumber-and-watir-kick-starting-your-testing/">3hv » Blog Archive » Cucumber and WATIR: kick-starting your testing</a></p>
<p><a href="http://wiki.github.com/aslakhellesoy/cucumber">Home &#8211; cucumber &#8211; GitHub</a></p>
<p><a href="http://watir.com/">Watir</a></p>
<p><a href="http://gitrdoc.com/brynary/webrat/tree/master/">brynary-webrat :: gitrdoc</a></p>
<p><a href="http://wiki.github.com/aslakhellesoy/cucumber/php">PHP &#8211; cucumber &#8211; GitHub</a></p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=e3ae0435-5e7d-8515-9027-944164d19e68" /></div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[TDD - Test Driven Development/Design]]></title>
<link>http://enerbilitytesting.wordpress.com/2009/11/26/tdd-test-driven-developmentdesign/</link>
<pubDate>Thu, 26 Nov 2009 11:06:53 +0000</pubDate>
<dc:creator>Geoffrey S Lakings</dc:creator>
<guid>http://enerbilitytesting.wordpress.com/2009/11/26/tdd-test-driven-developmentdesign/</guid>
<description><![CDATA[A relatively new concept of coding is becoming more mainstream; what do you think of writing test co]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>A relatively new concept of coding is becoming more mainstream; what do you think of writing test code prior to actually writing the code itself.  Sounds a little strange and against the thought of the mainstream coding paradigm where the test itself is done after the code has been written prior to implementation. </p>
<p>However, through TDD coding can actually be done quicker, meeting user requirements, and requiring less timely maintenance than in coding the old fashioned way.</p>
<p>As a coder would you rather spend more time debugging, refactoring, or being able to develop new code to meet yet another never-ending user requirement.  TDD enables the coder to spend less time babysitting the code because the tests are in place to provide a first line of security.</p>
<p>An excerpt from Wikipedia</p>
<p>Test-driven development (TDD) is a software development technique that relies on the repetition of a very short development cycle: First the developer writes a failing automated test case that defines a desired improvement or new function, then produces code to pass that test and finally refactors the new code to acceptable standards. Kent Beck, who is credited with having developed or &#8216;rediscovered&#8217; the technique, stated in 2003 that TDD encourages simple designs and inspires confidence.</p>
<p>Test-driven development is related to the test-first programming concepts of extreme programming, begun in 1999, but more recently has created more general interest in its own right.</p>
<p>Programmers also apply the concept to improving and debugging legacy code developed with older techniques.  Test-driven development requires developers to create automated unit tests that define code requirements before writing the code itself. The tests contain assertions that are either true or false. Passing the tests confirms correct behavior as developers evolve and refactor the code. Developers often use testing frameworks, such as xUnit, to create and automatically run sets of test cases.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Agile revelations part 2]]></title>
<link>http://implementingagile.wordpress.com/2009/11/21/agile-revelations-part-2/</link>
<pubDate>Sat, 21 Nov 2009 23:04:52 +0000</pubDate>
<dc:creator>Paul Harrington</dc:creator>
<guid>http://implementingagile.wordpress.com/2009/11/21/agile-revelations-part-2/</guid>
<description><![CDATA[My last Agile Revelations post was an unexpected foray into the reasons behind why I love Agile so m]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>My last <a href="http://implementingagile.wordpress.com/2009/09/11/agile-revelations/">Agile Revelations</a> post was an unexpected foray into the reasons behind why I love Agile so much. Written on a Friday night, a bit bored, it started me thinking about my career in software development and how I got to this point in my life.</p>
<p>So if you weren&#8217;t put off by my previous post and are still interested in what motivates people like me to pursue this most rewarding of methodologies then read on&#8230;&#8230;..</p>
<p>So where was I? Oh yes, I was still in my first development job and I&#8217;d just finished reading <a href="http://www.amazon.co.uk/Extreme-Programming-Explained-Embrace-Change/dp/0321278658">Extreme Programming: embrace change</a> by Kent Beck &#8211; the book which single-handedly inspired me to take on Agile. I&#8217;d been in that role for about a year by the time I finished the book and at around the same time I completed my full MCSD in my spare time. And it was lucky because within a month my company had no more C# work for me (they&#8217;d decided to re-write in java) so I took a junior C# developer role with a new company.</p>
<p>The development work there was challenging for a relatively in-experienced developer so I found it hard work implementing real WinForms and ASP.Net Web applications into production, but the hardest thing about it was that between projects there was a lot of &#8220;sitting around time&#8221; where we would be waiting for work (read spec documents as it was a classic waterfall environment!). This was so immensely painful as I hate being bored, having to pester people to give me work to do so in the end I used this time to improve my development skills and learn more about Agile.</p>
<p>The funny thing is that nowadays “being Agile” is such a buzz word and everybody and his dog is claiming that their company is doing it. But at the time it still felt very new (well I guess it was in the UK) and it wasn’t enough to just read buzz word books about XP &#8211; I wanted to learn the coding principles behind Agile and understand what made these programmers (apparently) so talented.</p>
<p>So I spent loads of time reading blogs, researching who was saying the most about Agile and XP and (to name but a few) I came up with some very well known writers on these subjects: <a href="http://www.martinfowler.com/bliki/">Martin Fowler</a>, <a href="http://www.threeriversinstitute.org/blog/?p=29">Kent Beck</a> and my own personal God <a href="//codebetter.com/blogs/jeremy.miller/">Jeremy Miller</a>.</p>
<p>I quickly realised that an Agile methodogy is useless if you don&#8217;t know how to write quality code so I started buying books which concentrated on improving development skills and writing clean code, here are just a few I started out with:</p>
<p><a href="http://www.amazon.co.uk/Refactoring-Improving-Design-Existing-Technology/dp/0201485672">Refactoring</a> by Martin Fowler<br />
<a href="http://www.amazon.co.uk/Test-Driven-Development-Addison-Wesley-Signature/dp/0321146530">Test Driven Development</a> by Kent Beck<br />
<a href="http://www.amazon.co.uk/Enterprise-Application-Architecture-Addison-Wesley-signature/dp/0321127420">POEAA</a> by Martin Fowler<br />
<a href="http://www.amazon.co.uk/Head-First-Design-Patterns-Freeman/dp/0596007124">Head first Design Patterns</a> by the Freemans<br />
<a href="http://www.amazon.co.uk/Applying-Domain-Driven-Design-Patterns-Using/dp/0321268202">Applying DDD</a> by Jimmy Nilsson</p>
<p>And that was how I spent my 2nd year in software development. It was an interesting time and for anyone just starting out I would definitely recommend these writers (and obviously a whole load more now &#8211; you&#8217;ll have to wait for part 3 for those!). The only caveat I would say is that these guys are so good that I did sometimes feel out of my depth, thinking I would never be able to write code as well as them (which is probably still true but I do at least now try!). I think this was probably a very natural reaction but to counter it I would recommend that rather than just reading about the concepts, try to implement them as often as you can in production code.  With that said, the best way to ultimately learn is to find an environment with technically excellent, like minded people, eager to learn the same values and able to implement them in production.</p>
<p>Enter <a href="www.uswitch.com">uSwitch</a> stage left <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Until next time&#8230;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA["Eat your own dog food" ou use TDD.]]></title>
<link>http://robsonvf.wordpress.com/2009/11/07/eat-your-own-dog-food-ou-use-tdd/</link>
<pubDate>Sat, 07 Nov 2009 04:21:40 +0000</pubDate>
<dc:creator>robsonvf</dc:creator>
<guid>http://robsonvf.wordpress.com/2009/11/07/eat-your-own-dog-food-ou-use-tdd/</guid>
<description><![CDATA[como já diria Joel Spolsky&#8230; este blog já está fedendo a cupim (não, Joel não disse isso, na ve]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>como já diria <a href="http://joelonsoftware.com/" target="_blank">Joel Spolsky</a>&#8230; este blog já está fedendo a cupim (não, Joel não disse isso, na verdade do que se trata dele terminou nas reticências e tinha a ver com o titulo do post) mas tudo bem, esta é uma rapidinha que, se <a href="http://twitter.com/irobson" target="_blank">eu</a> tivesse um numero consideravel de seguidores no twitter, seria um twitt&#8230; mas, como eu não gosto do twitter e nem quero que você me siga, vai pra cá mesmo.</p>
<p>Tudo que você faz, o faz como se você mesmo fosse usar? Pense nisso antes de construir a próxima linha de código lá no seu trabalho, esqueça seu chefe chato (não que o meu seja, caso o mesmo leia este post&#8230;) e codifique como se você mesmo fosse seu próprio usuário, como se você dependesse do seu próprio sistema para realizar seu trabalho.</p>
<p>Afinal de contas meu caro colega, os usuários gostariam tanto, mas tanto, que o que tu faz realmente funcionasse, que eles seriam capazes de te dar um beijo nas nadegas a cada dia de caixa fechado sem bug no sistema. E eu, sendo o cara que irá dar manutenção no seu código, adoraria tanto ver uma suite de testes unitários bem construidos quando o pegasse, que seria capaz de.. te pagar uma Polar bem gelada no boteco mais badalado da cidade baixa aqui de POA.</p>
<p>&#8220;Ah, mas eu já escrevo todo aquele código e testo tudo no main..  ainda tenho que escrever testes unitários pra ele?&#8221; Amigão, se tu quiser não precisa mais escrever este código todo.. escreva apenas os testes então. Ééé, isso mesmo. Esqueça aquela coisa toda logo de cara e vá direto aos seus @Test.. apenas coloque na cabeça: só entregue este código depois que os testes passarem! Se por acaso, tu ter que codificar um pouco para os testes passarem, beleza, tu faz classe a classe, mas espere, a classe não precisa existir para tu escreve-la pela primeira vez no seu teste&#8230; deixe o Eclipse chorar mesmo, só depois tu cria, ou melhor, rode a droga do teste sem a classe, para tu VER na tela que nada funciona sem a presença da maldita classe. É bem simples, não precisa ler um livro para começar.. são regrinhas básicas: da direita (seus testes) &#60;simula erro&#62; para a esquerda (implementação de uma pequena porção de código) &#60;testa&#62;.</p>
<p>&#8220;Mas quando eu sei que não preciso mais testar?&#8221; Quem disse que não precisa mais testar? Sempre que tu tocar aí tu vai testar, a unica diferença é que não precisará mais se preocupar com o que já está testado, pois se der algum tipo de erro, tu saberá exatamente onde consertar. Eu mesmo, sei quando não preciso mais testar quando o código que eu preciso para entregar a minha estória está pronto e é suficiente, pois de acordo com o TDD, se ele já está pronto, é porque existe um teste para ele!</p>
<p>Finalizando.. &#8220;eat your own dog food&#8221; .. estou ficando louco ou:</p>
<p>a propósito (falando em loucos), aproveitando a presença do <a href="http://twitter.com/SpringRod" target="_blank">Rod Johnson</a> na <a href="http://thedevelopersconference.com.br" target="_blank">TDC</a>, nos diga Rod: o que faz a SpringSource, usar PHP no seu portal?<a href="http://www.springsource.com/index.php"> http://www.springsource.com/index.php</a>, Por quê não o nosso amigo SpringMVC?</p>
<p>E que calor infernal em Porto Alegre&#8230;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Test Driven Development -- How to start with a test]]></title>
<link>http://danilogurovich.wordpress.com/2009/11/03/test-driven-development-how-to-start-with-a-test/</link>
<pubDate>Tue, 03 Nov 2009 18:00:41 +0000</pubDate>
<dc:creator>Danilo</dc:creator>
<guid>http://danilogurovich.wordpress.com/2009/11/03/test-driven-development-how-to-start-with-a-test/</guid>
<description><![CDATA[Test driven development is mystical to anyone that hasn&#8217;t done it from the ground-up. It]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Test driven development is mystical to anyone that hasn&#8217;t done it from the ground-up. It&#8217;s almost like riding a bike; you really don&#8217;t know how easy it is and how much fun you can have with it until you get up and going. When the training wheels are off, it then becomes a brand new world full of possibilities.</p>
<p>I have been writing unit tests for years. Having come to the Java game later than most of my colleagues, I really like to make sure that everything I commit to my various development communities are well-tested and as clean as I can make them. Unit testing has allowed me to verify this in two different ways. First, it guarantees that what I&#8217;ve writting works, and more importantly, it makes me keep my code simple. Frankly, if I start writing a test and it becomes a dependency-driven, closely-coupled to the implementation monster, I can pretty much guarantee that the code is going to be the same. I&#8217;ll try to refactor this and use my tests in this manner as a guage for it&#8217;s quality.<!--more--></p>
<p><em>So exactly HOW would I begin development by writing a test BEFORE I write any actual code, and WHY would I even want to? </em></p>
<p>We&#8217;ll address the &#8220;why&#8221; aspect first. &#8220;Old School&#8221; developers that I learned most of my skills from would create &#8220;fake&#8221; layers that the code that they were writing would have to talk to. A &#8220;fake layer&#8221; is defined as some type of data or code that simulates the functionality of an &#8220;expected&#8221; production-level deployment.</p>
<p>These &#8220;fake layers&#8221; would be similar to tests, but these guys wouldn&#8217;t write tests because they never did in the past (and some still don&#8217;t!). Testing just gives you a better framework for creating fake layers that you can create your code around.</p>
<h3>HOW do you start with a test?</h3>
<p>It&#8217;s actually quite simple. Let&#8217;s say you will be writing an application that talks to a database that has been created (you could even start without the database and just an ER diagram, but let&#8217;s keep it kinda simple). Looking at your requirements, you are probably going to implement CRUD operations against it. You start thinking about what the interface for the Data Access Object is going to look like. <em>Hmmmm &#8212; Let&#8217;s see &#8212; CREATE, READ, UPDATE, DELETE</em>. So your simple Interface has four methods.</p>
<p>Now start with a test. Create a class called MyDAOTest. MyDAOTest will test the <strong><em>Implementation Class</em></strong> for the interface&#8217;s methods. When we create a method in the test that tests well, we then create the interface method, then the move the test method, with proper modifications, into the a new <em>MyDAOImpl</em> class. It makes you create very smart tests that ensure you are &#8220;CRUD-ing&#8221; the data you expect. Coding in this way also creates the implementation to your interface at the simultaneously with the test. Finally, it makes you think about the interface and the implementation, and affects your overall design in a very positive light.</p>
<p>Now let&#8217;s take it further. You&#8217;ve created all the methods in your Impl class and your Interface methods can be extracted and the actual interface is now written and, for the time being, complete. Now let&#8217;s write a test that <em>calls</em> the Interface and implements a <em>new</em> Implementation Class through it. You can now see how clean your Interface is &#8212; how easy are your methods to use, how are things being cleaned up, and finally, how are exceptions being caught? Are you satisfied with the results so far? If so, proceed to the next layer!</p>
<p>The next layer may possibly involve a creating a Session Facade to allow for user interaction with the database (simple implementation, obviously). You can then create an Object model that translates the Database relationships into some type of presentation-level object gouping, and write tests to reflect this. It becomes very obvious what objects you need when you start writing a test that outputs the data that you want in a conditioned manner. Your first cut at it may look like horrible code! It may be some type of monolithic monster, but then you can see how things need to be split up. You keep splitting things up and writing tests around it, and sooner rather than later, you are suprisingly code-complete!</p>
<h3>Do what works for you.</h3>
<p>Even after all this I&#8217;m sure that some peoople are completely poo-pooing what I&#8217;m saying. That&#8217;s fine if it works for you. I&#8217;ve found that even if I begin by writing code to tests and continue writing tests and interfaces and all kinds of extra, &#8220;non-production&#8221; code, my productivity jumps dramatically as the project continues  because I write less and less code as the project nears completion.</p>
<p>It&#8217;s about making everything solid. Using TDD, you&#8217;ll be writing one line of code to your previous ten, and when your &#8220;business guy&#8221; walks in and asks for a change, you&#8217;ll be going home at 5 instead of having your car languish in the parking lot after midnight. You&#8217;ll also have more confidence in the code that is checked in, and when things go wrong and the inevitable finger-pointing starts, you won&#8217;t be a pointee!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JUnit 4.7]]></title>
<link>http://uhohcoder.wordpress.com/2009/10/03/junit-4-7/</link>
<pubDate>Sat, 03 Oct 2009 00:42:35 +0000</pubDate>
<dc:creator>ngmilne</dc:creator>
<guid>http://uhohcoder.wordpress.com/2009/10/03/junit-4-7/</guid>
<description><![CDATA[Just tried out one of the new features of JUnit 4.7 &#8211; @Rules. One I especially like allows you]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Just tried out one of the new features of <a title="JUnit 4.7" href="http://www.junit.org/node/574" target="_blank">JUnit 4.7</a> &#8211; @Rules. One I especially like allows you to perform further tests on thrown exceptions, as an extension to the @Test(expected=&#8230;) from earlier versions of JUnit. Putting back the check on thrown exceptions to the end of the unit test allows you to check for object end states and more details around the exception (message etc). However, if you&#8217;re also a fan of <a href="http://www.jmock.org" target="_blank">jMock</a> then beware &#8211; the @RunWith(JMock.class) appears to prevent detection of the @Rules annotations, failing tests utilizing @Rules which pass without the @RunWith annotation. There seems to be little downside to running your tests without the @RunWith annotation, presumably less integration into JUnit 4 reporting.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[to RSpec or not to RSpec]]></title>
<link>http://charpcfn.wordpress.com/2009/10/01/to-rspec-or-not-to-rspec/</link>
<pubDate>Fri, 02 Oct 2009 03:04:18 +0000</pubDate>
<dc:creator>ggnextmap</dc:creator>
<guid>http://charpcfn.wordpress.com/2009/10/01/to-rspec-or-not-to-rspec/</guid>
<description><![CDATA[I took another look at RSpec today. I tried to re-write the script using a test driven development m]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I took another look at RSpec today. I tried to re-write the script using a test driven development method but am finding it harder to use than expected. I think I just have to shift my brain into programming TDD style. I really didn&#8217;t come up with any good code, I must have started over at least 10 times. I started with things like it &#8220;should accept a parameter &#8211;operation that takes either &#8216;add&#8217; or &#8217;sub&#8217; as it&#8217;s value&#8221; Then I would read RSpec docs and try to test tha&#8230;needless to say it&#8217;s a good way to learn about RSpec albeit rather slow. Hopefully I can move my brain to this new style of thinking. It seemed so easy at first but once you try it, it&#8217;s actually kind of difficult to do.</p>
<p>Here is the list of requirements I&#8217;m going to be working off of.</p>
<ul>
<li>it &#8220;should accept two parameters, an operation that is either add or sub and a time value formatted at least with one digit. It should also accept two arguments, an in_file and na out_file&#8221;</li>
<li>it &#8220;should add or subtract time based on the set operation&#8221;</li>
<li>it &#8220;should modify the time by the amount passed in as a parameter of &#8211;time&#8221;</li>
<li>it &#8220;should read times and all other lines from the first file&#8221;</li>
<li>it &#8220;should write modified times and unmodified other lines to the second file&#8221;</li>
</ul>
<p>IF you can get these tests to pass, then you&#8217;ve got yourself a working program and RSpec test to go with it as well as some documentation!</p>
<p>Until next time&#8230;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Shift Subtitle, RSpec]]></title>
<link>http://charpcfn.wordpress.com/2009/09/29/shift-subtitle-rspec/</link>
<pubDate>Wed, 30 Sep 2009 00:34:24 +0000</pubDate>
<dc:creator>ggnextmap</dc:creator>
<guid>http://charpcfn.wordpress.com/2009/09/29/shift-subtitle-rspec/</guid>
<description><![CDATA[Sometimes it&#8217;s just nice to have everything you need in your apartment and you can just sit ar]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Sometimes it&#8217;s just nice to have everything you need in your apartment and you can just sit around and code :]</p>
<p>I decided today to try my hand at some unit testing using RSpec, as was suggested at the end of the challenge. I haven&#8217;t done much testing before so this seems like a good way to get started. The code I submitted includes a class definition as well as some imperative programming all in one. It would have been nice to separate that out, but this was supposed to be one script that works using the standard library. However, since this is beyond the challenge I&#8217;m going to test the class I&#8217;ve made, SubtitleTime. You can see it in the <a href="http://charpcfn.pastebin.com/f594e4212">pastebin</a>. It takes two parameters, a string in the format of HH:MM:SS,mmm and a &#8216;modifier&#8217; that is either add or sub.</p>
<p>So starting off with RSpec first you have to &#8216;describe&#8217; the class. Then you use a function named &#8216;it&#8217; and write what the class should do. For example:</p>
<pre>describe SubtitleTime do
    it "should be able to add another timestamp to itself" do
    end
end</pre>
<p>Once that part of the code is written, then you just have to add some filler lines to actually test the code. This code above could be expanded to look like this:</p>
<pre><span style="text-decoration:line-through;">describe SubtitleTime do
    it "should be able to add another timestamp to itself" do
        subtitletime.should add_time(another_timestamp)
    end
end</span> # note: this has been crossed out as after reading more about RSpec, this just doesn't make sense.</pre>
<p>Well after having written a few test cases and finally understanding what RSpec is all about, I feel like I should do this the right way and see what happens to my class if I built it using TDD (Test Driven Design). It initially seems very difficult to build up a test suite on an already existing piece of code. So let&#8217;s get started with some test cases.</p>
<p>First off we want the class to have a time that, before altered, is equal to the initial time. The code for that would look like this:</p>
<pre>describe SubtitleTime do
    it "should have time equal to the initial time before the class is altered" do
        subtime = Subtitletime.new(:initial)
        subtitle.time.should == :initial
    end
done</pre>
<p>Then When you run this test with the command &#60;spec subtitletime_spec.rb&#62; it will fail saying there is no class SubtitleTime. Simple. The idea behind TDD is that you make a test case, have it break, then fix it. An occasional (or after each iteration) step of refactoring your code should also be included in this process. So now I&#8217;ll make a class SubtitleTime</p>
<pre>class SubtitleTime
end</pre>
<p>This fixes the first error but we still get another error as the test is run. But that&#8217;s all I have time for right now, I was using an <a href="http://www.ibm.com/developerworks/web/library/wa-rspec/">ibm guide to rspec</a>. That should make things fairly clear. There is a lot to go over and a lot to do, but I&#8217;ll get back to this hopefully sooner rather than later and then finish up this challenge&#8217;s extras!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Cherrypicking what works...]]></title>
<link>http://featuresplat.wordpress.com/2009/09/26/cherrypicking-what-works/</link>
<pubDate>Sat, 26 Sep 2009 21:46:12 +0000</pubDate>
<dc:creator>featuresplat</dc:creator>
<guid>http://featuresplat.wordpress.com/2009/09/26/cherrypicking-what-works/</guid>
<description><![CDATA[I attended a panel discussion sponsored by Rally Software this month. The panel was composed of indi]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I attended a panel discussion sponsored by Rally Software this month. The panel was composed of individuals from different industries, each holding quite different roles in their organizations. They each contributed to a discussion of Agile and its benefits and challenges through the lens of their respective roles. This was probably what made the dialogue intriguing for me. The executive-level presentations made sense, and they focused on metrics and strategies for management approval, the buy-in and then follow-up phases, reporting on the velocity and productivity gains Agile can bring to product development.</p>
<p>However, the technically focused management reminded me of bad habits that are often overlooked in the rush to see rapid productivity improvements. I cannot present all the materials here without permission, but I will reiterate the basic message (and thank you Heather for this insight)&#8230;<br />
Agile as a process is a collection of practices that works as a &#8220;collection&#8221;. Each practice is coupled with, and balanced by, the other practices. Sort of an ecosystem, were the inter-dependencies result in success or assured extinction for all. New practitioners, startup ventures, pilot programs and specific industries all tend to adopt Agile in a primordial way, by collecting the most relevant practices and adding them to the &#8220;soup&#8221;. Teams build an Agile &#8220;soup&#8221; based on need and how much change and training they can absorb quickly. A very common sense and practical way to get rolling with Agile. This is why training and coaching are so important to new adopters, it is often the missing key to success in these lean, budget cutting times.</p>
<p>Nonetheless, as organizations grow and the process matures, managers want to add to the maturity of their Agile practice by &#8220;cherrypicking&#8221; additional practices and adding them to their Agile &#8220;soup&#8221;. Here is where things can go awry. The practices and the disciplines are not intended to be mix and match. As stated in earlier posts, this is where &#8220;hybrid&#8221; approaches tend to evolve and teams try adding in waterfall practices and milestone gating steps to resolve where they are having issues. This is not wrong (but nor is it Agile). These modifications and &#8220;cherrypicking&#8221; of additional practices is where a clear understanding of Agile is required. For example: There is a growth in the number of teams and an explosive growth in the interdependent nature of the work being done, the group decides to add a &#8220;Scrum of Scrums&#8221; to have better team oversight. Here the group is adding a practice that fits into the Agile framework and upholds the ecosystem. Another example: A new team is added to work on platform services to be used by all the teams, this new team is technically strong and very dedicated to delivering on time to their co-dependent team mates. They breakdown all their user stories and pre-plan each in detail and discuss all the tasks and tests required. When they are finally certain they understand all the work, they commit to the stories and start the sprint. Unfortunately, this is waterfall estimation at a task level and not Agile. Even though the team&#8217;s intentions are good, they are operating as a rogue waterfall team compared to the other Agile teams by doing extensive task level estimation work prior to committing to stories. The other risk is that this team may be blocking the goal of &#8220;collective code ownership&#8221; as they focus and specialize.</p>
<p>Returning to some of the codependent practices, here is a short list of elements that work inter-dependently in an Agile ecosystem:</p>
<ul>
<li>TTD (test driven development)</li>
<li>Pair programming</li>
<li>Collective Code ownership</li>
<li>Continuous Integration</li>
<li>Simple Design</li>
<li>Refactoring</li>
<li>Automated Acceptance Testing</li>
<li>Customer Involvement</li>
<li>Adaptive Planning</li>
<li>Sustainable Pace</li>
<li>Small Iterations and Releases</li>
<li>Continuous Feedback</li>
<li>QA Involvement</li>
<li>Empowered Teams</li>
<li>Eliminating Waste</li>
<li>&#8220;Done Done&#8221; Stories</li>
<li>Estimate-able Stories</li>
<li>Iteration Velocity</li>
<li>Inspect and Adapt (Retrospectives)</li>
<li>Whole Teams</li>
</ul>
<p>When teams are inspecting and adapting (often through retrospectives) then helpful practices may be added or may evolve. However the panelists were clear in this message,  when &#8220;cherrypicking&#8221; to grow process improvements it is important to recognize how the ecosystem works as a whole and select component practices wisely so as not to disrupt the entire system. Remember to focus on complementing the practices the team has successfully adopted and reflect of the health of the ecosystem.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Test Driven Development and Project Euler Series: Palindrome Divisible by Three Numbers]]></title>
<link>http://koolaborate.wordpress.com/2009/09/06/test-driven-and-project-euler-series-palindrome-divisible-by-three-numbers/</link>
<pubDate>Sun, 06 Sep 2009 23:45:26 +0000</pubDate>
<dc:creator>koolaborate</dc:creator>
<guid>http://koolaborate.wordpress.com/2009/09/06/test-driven-and-project-euler-series-palindrome-divisible-by-three-numbers/</guid>
<description><![CDATA[Disclaimer: I will NOT disclose what the answers are to these problems.  The intent is that the test]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><em><strong>Disclaimer</strong>: I will NOT disclose what the answers are to these problems.  The intent is that the testing is just as important, and in most cases, more than the answer.  If you want to know what the answer is without solving the problem, a simple google search will tell you what it is.</em></p>
<p><strong>Background</strong>:</p>
<ul>
<li>If you are not familiar with the series, <a href="http://koolaborate.wordpress.com/2009/09/03/test-driven-development-series-using-project-euler/">please read this</a>.</li>
<li>This is Java driven as well as JUnit 4.</li>
<li>You are familiar with TDD tenants.</li>
</ul>
<p><strong>References</strong>:</p>
<ul>
<li><a href="http://koolaborate.wordpress.com/2009/09/03/test-driven-development-series-using-project-euler/">All references to this series can be found in the parent blog</a>.</li>
</ul>
<p><a href="http://projecteuler.net/index.php?section=problems&#38;id=4"><strong>Problem</strong></a>:</p>
<p>&#8220;A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.</p>
<p>Find the largest palindrome made from the product of two 3-digit numbers.&#8221;</p>
<p><strong>Difficulty</strong>: Easy</p>
<p><strong>The Test File</strong>:</p>
<ul>
<li>Please download it <a href="http://www.koolaborate.com/source/src/com/koolaborate/easy/PalinTest.java">here</a>.</li>
</ul>
<p><strong>Explanation</strong>:</p>
<p>A brute force approach would be to go from 10,000 to 998,001 and evaluating each number for the two criterea:</p>
<ul>
<li>Is this number a Palindrome?</li>
<li>Is this number a product of two three digit numbers?</li>
</ul>
<p>Not being a mathematician, I kind of liked a brute force idea, but I tweaked it a bit.  Instead of an incremental approach from min to max, I decided to use a decremental approach.  I suspected that the answer should be in the 900,000&#8217;s.  I only have to traverse through, at most, 100,000 integers.</p>
<p>For determining the divisibility, I was also going to take a brute force approach as well, but I was going to make an assumption.  That is, I&#8217;m going to guess that both products will be between 800-999.  So the determination will be a decremental loop starting from 999.  If the palindrome is evenly divisible by that number, I would divide the palindrome with that number, and check if the product is less than 1000.  So it goes like this:</p>
<ul>
<li>Start from 998,001 and decrement by one in a loop.</li>
<li>Is the number a palindrome?</li>
<li> If so, is it divisible by a number in a decremental range starting from 999, and ending in 800.</li>
<li> If so, is the product of the palindrome and that number less than 1000?</li>
<li> Good.  Print the number, or print the number and exit.</li>
</ul>
<p>The hardest thing about this problem then was then evaluating whether or not a given number is a palindrome or not.  I know what a palindrome is, but I never implemented an algorithm that evaluated a palindrome.  With strings, it&#8217;s slightly easier because you can easily compare first and last characters in Java and then strip them.  You have charAt at your disposal, substring and many implementations of strip (first and last chars).</p>
<p>With numbers how do you do that?  I didn&#8217;t know, so I had to write it out on paper.  After that, it was fairly straight forward.  I had to write an algorithm that compared the first and last digits of the number using modulo based on ten and divisors based on 10.  Then I had to write an extractor that stripped out the left and right most digits.</p>
<p>Stop if the stripped digit is either single or double digits.  If it gets down to single digits, the number is a palindrome.  i.e.: 151 is a palindrome because the first and last digits are equal and the remainder is 5.  This works for all three digit (or odd) digit numbers.</p>
<p>Stop if the stripped remainder is two digits.  If the number is a palindrome (22, 33, etc) return true.  Else return false.</p>
<p><strong>Implementation Details</strong>:</p>
<p>Methods shouldTestGetLeftMostNumber, and shouldTestGetRightMostNumber were my first two test methods.  It was easy to implement (10 based divisors retrieved left most numbers, modulo retrieved right most numbers).  I started with one test first, for example:</p>
<ul>
<li>Given the number 5, I expect that left most number is 5.  Assert that 5 is expected against the actual, 5.</li>
</ul>
<p>Then the tests followed&#8230;</p>
<ul>
<li>Given the number 61, I expect that the left most number is 6.  Assert that expected and actual are equal.</li>
<li>You can do tests for any random 3, 4, 5 and 6 digit numbers.</li>
</ul>
<p>Getting the right most number was similar and just as trivial.  Example:</p>
<ul>
<li>Given a number 462, I expect that the right most number is 2.  Assert!</li>
<li>I didn&#8217;t do negative cases because I used random numbers.</li>
</ul>
<p>So a palindrome checker is fun to implement.</p>
<ul>
<li>Are the two numbers  on the ends equal?  If not, stop and return false;</li>
<li>If so return the center.</li>
<li>Stop and return true if the remainder is single digit.</li>
<li>Stop and return false if the remainder is double digit but not a palindrome.</li>
<li>Stop and return true if the remainder is double digit and is a palindrome (22, 33,  44, etc).</li>
</ul>
<p>That&#8217;s it!!!  Now, how you implement your methods are totally up to you.  You can use recursion for the palindrome checker, but I didn&#8217;t.  I used iterative approaches for speed (although, unlike the Fibonacci problem, recursion shouldn&#8217;t pose to much of a performance hit).</p>
<p>Divisibility by three digits is easy as well.  It&#8217;s trivial so I need not write out the implementation.  Just guess that the range is between 999-800, decremented.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Rhino Mocks and AssertWasCalled MethodOptions]]></title>
<link>http://kashfarooq.wordpress.com/2009/09/03/rhino-mocks-and-assertwascalled-methodoptions/</link>
<pubDate>Thu, 03 Sep 2009 19:40:28 +0000</pubDate>
<dc:creator>Kash</dc:creator>
<guid>http://kashfarooq.wordpress.com/2009/09/03/rhino-mocks-and-assertwascalled-methodoptions/</guid>
<description><![CDATA[I always seem to struggle to find examples of how to use MethodOptions in Rhino Mocks, so here is so]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I always seem to struggle to find examples of how to use MethodOptions in Rhino Mocks, so here is some code.</p>
<p>Assume you have the following dependency:</p>
<pre class="brush: csharp;">
public interface IDependency {
   void SomeMethod(int number);
   void SomeMethod(ComplexType complexType);
}

public class ComplexType {
   public string Name { get; set; }
}
</pre>
<p>And your system under test calls this dependency like this:</p>
<pre class="brush: csharp;">
public class SystemUnderTest {
   private readonly IDependency dependency;
   public SystemUnderTest(IDependency dependency) {
      this.dependency = dependency;
   }

   public void DoSomething() {
       dependency.SomeMethod(9);
       dependency.SomeMethod(3);
   }

   public void DoSomethingElse() {
       dependency.SomeMethod(new ComplexType{Name = &#34;London&#34;});
   }
}
</pre>
<p>You can use MethodOptions to check that the dependency was called correctly.</p>
<p>First, let&#8217;s check that SomeMethod was called twice with integers greater than 1:</p>
<pre class="brush: csharp;">
[Test]
public void EnsureDependencyCalledTwiceWithAnIntegerGreaterThanOne() {
  var dependency = MockRepository.GenerateStub&#60;IDependency&#62;();
  var systemUnderTest = new SystemUnderTest(dependency);
  systemUnderTest.DoSomething();

  dependency.AssertWasCalled(x =&#62; x.SomeMethod(0),
                                                 options =&#62;
                                                 {
                                                     options.Repeat.Twice();
                                                     options.Constraints(Is.GreaterThan(1));
                                                     options.Message(&#34;SomeMethod should have been called twice with integers greater than 1&#34;);
                                                 });
}
</pre>
<p>Next, let&#8217;s check that the correct ComplexType was sent to SomeMethod</p>
<pre class="brush: csharp;">
[Test]
public void EnsureDependencyCalledWithCorrectComplexType() {
  var dependency = MockRepository.GenerateStub&#60;IDependency&#62;();

  var systemUnderTest = new SystemUnderTest(dependency);
  systemUnderTest.DoSomethingElse();

  Func&#60;ComplexType, bool&#62; checkArgs = arg =&#62; arg.Name == &#34;London&#34;;
  //The above line can be written with an anonymous method instead:
  //Func&#60;ComplexType, bool&#62; checkArgs = delegate(ComplexType arg) { return arg.Name == &#34;London&#34;; };

  dependency.AssertWasCalled(x =&#62; x.SomeMethod(new ComplexType()),
                                                        options =&#62; {
                                                           options.Callback(checkArgs);
                                                           options.Message(&#34;Name sent was not London&#34;);
                                                        });
}
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[About stubs, fakes and mocks]]></title>
<link>http://sdesmedt.wordpress.com/2009/09/02/about-stubs-fakes-and-mocks/</link>
<pubDate>Wed, 02 Sep 2009 19:35:49 +0000</pubDate>
<dc:creator>serge desmedt</dc:creator>
<guid>http://sdesmedt.wordpress.com/2009/09/02/about-stubs-fakes-and-mocks/</guid>
<description><![CDATA[Test driven development is not an easy subject. And to be honest, I&#8217;ve not been convinced of i]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Test driven development is not an easy subject. And to be honest, I&#8217;ve not been convinced of it&#8217;s usefullness when first reading about it, witnessing <a href="http://sdesmedt.wordpress.com/2006/07/28/the-practical-traveller/">this post</a>. What I do believe firmelly is the usefulness of unit testing. But I have found that overall resistance to unit testing is rather big mostly because if not done well it turns out to be rather timeconsuming.</p>
<p>Now, let me start by saying I&#8217;m not an expert on the subject. I&#8217;ve tried applying it to some projects with some success and wanted to use it extensively in the next major release of my Offline Maps project. So I did some research to find where I could improve and my first subject was mock objects. </p>
<p>It turned that mocks are only a part of the complete picture.</p>
<h2>Ok mocks, but what about stubs, dummies, fakes, etc&#8230;</h2>
<p>There is a lot of lingo surrounding unit testing. Before we get any deeper on mock objects lets clearly define what they are and more importandly, what they are not and what differentiates them from stubs, fakes, etc&#8230;</p>
<h3>Stubs</h3>
<p>According to <a href="http://codebetter.com/blogs/jeremy.miller/archive/2005/12/19/135757.aspx">Jeremy Miller</a>, the difference between mocks and stubs is mostly in the sort of testing you&#8217;re performing:</p>
<blockquote><p>The real difference between a mock and a stub is in the style of unit testing, i.e. state-based testing versus interaction testing.  A stub is a class that is hard-coded to return data from its methods and properties. You use stubs inside unit tests when you’re testing that a class or method derives the expected output for a known input.</p></blockquote>
<p><a href="http://xunitpatterns.com/Test%20Stub.html">Gerard Meszaros</a> provides a bit more detail:</p>
<blockquote><p>In many circumstances, the environment or context in which the system under test (SUT) operates very much influences the behavior of the SUT. To get good enough control over the indirect inputs of the SUT, we may have to replace some of the context with something we can control, a Test Stub.</p></blockquote>
<p>So, you use stubs if you want to provide data to your system under test and the outcome of your system under test is dependend on the content of that data. A good example would be an object which has as input the current date and for example calculates yesterday. If you where to use the effective current date, then you could never write a test because each different day you execute the test would use a different current day, thus calculate a different yesterday and thus the value against which you want to check would change every day. If you however create a stub which provides a current day that you can set fixed, then you can reproduce the result whenever you want:</p>
<p>An example:</p>
<p>The code we want to test is the following:</p>
<pre class="brush: csharp;">
public ITodayProvider TodayProvider { get; set; }
public DateTime Yesterday
{
	get { return TodayProvider.Today.AddDays(-1); }
}
</pre>
<p>The implementation of ITodayProvider used in the application uses the system date:</p>
<pre class="brush: csharp;">
public DateTime Today
{
	get { return DateTime.Today; }
}
</pre>
<p>The implementation of ITodayProvider used in the test however allows to set the date that will be returned:</p>
<pre class="brush: csharp;">
public DateTime Today
{
	get;
	set;
}
</pre>
<p>The test with the ITodayProvider using the system date does not produce repeatable results:</p>
<pre class="brush: csharp;">
[Test]
public void WithoutStubTest()
{
	CalculateYesterday yesterdayCalculator = new CalculateYesterday();
	yesterdayCalculator.TodayProvider = new TodayProvider();

	// Unless you execute this test exactly on 1st september 2009, this test will fail
	Assert.AreEqual(new DateTime(2009, 8, 31), yesterdayCalculator.Yesterday);
}
</pre>
<p>The test with the ITodayProvider which can be set does allow to produce repeatable results:</p>
<pre class="brush: csharp;">
[Test]
public void WithStubTest()
{
	CalculateYesterday yesterdayCalculator = new CalculateYesterday();
	TodayProviderStub stub = new TodayProviderStub();
	stub.Today = new DateTime(2009, 9, 1);
	yesterdayCalculator.TodayProvider = stub;

	// This test will always succeed, that is if you implementerd the yesterday calculation correctly.
	// It is however completely independent of the day the test is executed
	Assert.AreEqual(new DateTime(2009, 8, 31), yesterdayCalculator.Yesterday);
}
</pre>
<h3>Fakes</h3>
<p>Where a stub actually influences the system undertest, a fake only &#8220;fakes&#8221; an object in the system under test. Again according to <a href="http://xunitpatterns.com/Fake%20Object.html">Gerard Meszaros</a>:</p>
<blockquote><p>The SUT often depend on other components or systems. The interactions with these other components may be necessary but the side-effects of these interactions as implemented by the real depended-on component (DOC), may be unnecessary or even detrimental. A Fake Object is a much simpler and lighter weight implementation of the functionality provided by the DOC without the side effects we choose to do without.</p></blockquote>
<p>Matin Fowler in <a href="http://martinfowler.com/bliki/TestDouble.html">his post on different  kinds of test doubles</a> states  the following:</p>
<blockquote><p>Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production (an InMemoryTestDatabase is a good example) So whereas stubs don&#8217;t have any working functionality, fakes have. They just take some shortcuts. Stubs are typically hardcoded to return some value.</p></blockquote>
<p>As an example, suppose your object uses a webservice for retrieving some values, you may not be interested in setting up a connection to the webservice, provide a connection string, etc&#8230; because the actual webservice used is unimportant to your system under test. You also don&#8217;t want everyone executing your tests to be dependend on the availability of that webservice or detrimental behaviour like unavailable connections, timeouts and all that sort of stuff specific to webservices to mess up your test. In this case you could use a fake in webservice which provides the same functionality but is much easier in setup and which doesn&#8217;t exhibit the unwanted behaviour of unavailable connections and timeouts.</p>
<p>The code we want to test is the following:</p>
<pre class="brush: csharp;">
public ITodayProvider TodayProvider { get; set; }
public IDayRangeCalculatorService DayRangeService { get; set; }
public DateTime YesterdayUsingDayRangeService
{
	get
	{
		IDayRangeCalculator dayRangeCalculator = DayRangeService.ConnectToService();
		int daysBetween = dayRangeCalculator.DaysBetweenTodayAndYesterday();

		return TodayProvider.Today.AddDays(daysBetween);
	}
}
</pre>
<p>A fake implementation of the service allows to get away of all problems relating to connecting to and using of webservices:</p>
<pre class="brush: csharp;">
class DayRangeCalculatorServiceFake : IDayRangeCalculatorService
{
	#region IDayRangeCalculatorService Members

	public IDayRangeCalculator ConnectToService()
	{
		return new DayRangeCalculatorFake();
	}

	#endregion
}

class DayRangeCalculatorFake : IDayRangeCalculator
{
	#region IDayRangeCalculator Members

	public int DaysBetweenTodayAndYesterday()
	{
		return -1;
	}

	#endregion
}
</pre>
<p>By using the fake in the test we know our test will not fail because of problems related to the webservice. So if our test fails, then we know it&#8217;s because our algoritme failed:</p>
<pre class="brush: csharp;">
[Test]
public void WithDaysBetweenServiceFakeTest()
{
	CalculateYesterday yesterdayCalculator = new CalculateYesterday();
	TodayProviderStub stub = new TodayProviderStub();
	stub.Today = new DateTime(2009, 9, 1);
	yesterdayCalculator.TodayProvider = stub;

	yesterdayCalculator.DayRangeService = new DayRangeCalculatorServiceFake();

	// In this test we are only interested if the method returns the correct yesterday
	//  and not if the logging was done correctly
	Assert.AreEqual(new DateTime(2009, 8, 31), yesterdayCalculator.YesterdayWithLogging(new LoggingDummy()));
}
</pre>
<h3>Dummies</h3>
<p>Dummies have no influence at all on the tests. They are just used to provide values for method parameters, etc&#8230;</p>
<p><a href="http://martinfowler.com/bliki/TestDouble.html">Fowler</a>:</p>
<blockquote><p>Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists.</p></blockquote>
<p>Thus, you use a dummy if you test requires an object which thus not have any influence on the outcome of your test. An example could be a method called in your test which has some specific outcome you want to check but for example also take a logging object as a parameter. Remember we are unit testing and each test checks on some aspect of the object. So we want to check the specific outcome of calling the method but in this test we are not at all interested in the logging of the method. Then we provide a dummy logging object which actually thus nothing but allows us to call the method and check the expected outcome.</p>
<p>The code we want to test is the following:</p>
<pre class="brush: csharp;">
public ITodayProvider TodayProvider { get; set; }

public DateTime YesterdayWithLogging(ILogging logging)
{
	logging.LogMessage(&quot;Executing YesterdayWithLogging&quot;);
	return TodayProvider.Today.AddDays(-1);
}
</pre>
<p>In our test we don&#8217;t care about logging. So we provide a dummy logging class which does nothing:</p>
<pre class="brush: csharp;">
class LoggingDummy:  ILogging
{
	#region ILogging Members

	public void LogMessage(string message)
	{
	}

	#endregion
}
</pre>
<p>In our test we don&#8217;t have to worry about the logging</p>
<pre class="brush: csharp;">
[Test]
public void WithLoggingDummyTest()
{
	CalculateYesterday yesterdayCalculator = new CalculateYesterday();
	TodayProviderStub stub = new TodayProviderStub();
	stub.Today = new DateTime(2009, 9, 1);
	yesterdayCalculator.TodayProvider = stub;

	// In this test we are only interested if the method returns the correct yesterday
	//  and not if the logging was done correctly
	Assert.AreEqual(new DateTime(2009, 8, 31), yesterdayCalculator.YesterdayWithLogging(new LoggingDummy()));
}
</pre>
<p>Now, if all this is a bit overwhelming, don&#8217;t be concerned. Your test doubles will mostly be a mix of the above, or their focus or purpose will shift as shown by Daniel Cazzulino in his post<a href="http://www.clariusconsulting.net/blogs/kzu/archive/2007/12/21/47152.aspx">Mocks, Stubs and Fakes: it&#8217;s a continuum </a>.</p>
<h2>Mock objects, what problems to they solve ?</h2>
<p>In many  posts about the type of test doubles there is also the difference between test spies and mocks. From what I could find on them the difference is not that clear to me. So I will treat them as being the same. Of course, if you can explain the difference in a clear way, you&#8217;re welcome, or if you know a reference let me know.</p>
<h3>About behaviour</h3>
<p>We all know it but lets state it once more explicitely:<br />
Objects are instances of classes which exhibit both state and behaviour. </p>
<p>Anyone studying UML will agree that both the class diagram and the sequence diagram are needed to document the interactions of systems. Where the class diagram shows what properties the classes in the system have, the sequence diagram shows what the important method calls made by the objects are. So you could say that the class diagram documents the state of a system (not entirely thru) and the sequence diagram documents the behaviour of the system. And as you need both the class diagram and the sequence diagram you need both state testing and behaviour testing.</p>
<h3>When to use mock objects</h3>
<p>The main difference with traditional testing is that where traditional testing allows a more state-based approach of testing, mock objects provide a behaviour style of testing. We all know the traditional style of unit testing using frameworks like NUnit, MbUnit and there assert-style testing:</p>
<ol>
<li>Setup your test</li>
<li>Execute some action</li>
<li>Assert that the properties of the object under test are what you expect</li>
</ol>
<p>We assert that the state the object under test is in, is what we expect. To check this state, we check the values of the object&#8217;s properties.</p>
<p>Behaviour style testing on the other hand verifies the dynamic behaviour of the object under test. Remember that we are using mock objects to represent companion objects &#8220;on the edges of the object under test&#8221;. That is, objects used by our object under test. Now, sometimes we will want to know if our object under test calls a certain method with certain arguments of the companion object. The post <a href="http://www.developertesting.com/archives/month200503/20050311-UsingMockObjectsEffectively.html">Using Mock Objects Effectively</a> provides a great example:</p>
<blockquote><p>On closer inspection, it becomes clear that the application is not actually logging anything. Log4J is responsible for doing that. What the application is truly doing is sending a signal (a request) to log4j to log a message. That distinction is *very* important. The appropriate test then is simply to verify that the application is sending the correct signal to the service provider under the right conditions.</p></blockquote>
<p>We now get following test sequence:</p>
<ol>
<li>Setup your test</li>
<li>Execute some action</li>
<li>Assert that the required methods have been executed with the correct parameters and in the correct sequence</li>
</ol>
<p>We assert that the object under test executed the behaviour we expect. To check this behaviour, we check the methods it called and the arguments it provided to those methods.</p>
<p>So, using mock objects for behavioural testing can co-exist with the more traditional style of sate based testing.</p>
<p>Martin Fowler, him again, warns for some caveats when using mock style testing in his article <a href="http://martinfowler.com/articles/mocksArentStubs.html">Mocks Aren&#8217;t Stubs</a>:</p>
<blockquote><p>When you write a mockist test, you are testing the outbound calls of the SUT to ensure it talks properly to its suppliers&#8230;<br />
Coupling to the implementation also interferes with refactoring, since implementation changes are much more likely to break tests than with classic testing.</p></blockquote>
<h3>An example</h3>
<p>The code we want to test is the following:</p>
<pre class="brush: csharp;">
public ITodayProvider TodayProvider { get; set; }

public DateTime YesterdayWithLogging(ILogging logging)
{
	logging.LogMessage(&quot;Executing YesterdayWithLogging&quot;);
	return TodayProvider.Today.AddDays(-1);
}
</pre>
<p>In our test we don&#8217;t care about the exact output of the logging but we do care if the logging is called and if it is called with the correct arguments. So we want to record the methodcall and the arguments with which it got called:</p>
<pre class="brush: csharp;">
class LoggingMock:  ILogging
{
	public int NumberOfMethodCalls { get; private set; }
	public List&lt;String&gt; MethodCallArguments { get; private set; }

	#region ILogging Members

	public void LogMessage(string message)
	{
		NumberOfMethodCalls++;
		if (MethodCallArguments == null)
		{
			MethodCallArguments = new List&lt;string&gt;();
		}

		MethodCallArguments.Add(message);
	}

	#endregion
}
</pre>
<p>By recording the calls we can check in our test if the method got called and if the provided arguments where correct:</p>
<pre class="brush: csharp;">
[Test]
public void WithLoggingMockTest()
{
	CalculateYesterday yesterdayCalculator = new CalculateYesterday();
	TodayProviderStub stub = new TodayProviderStub();
	stub.Today = new DateTime(2009, 9, 1);
	yesterdayCalculator.TodayProvider = stub;
	LoggingMock loggingMock = new LoggingMock();

	// In this test we want to see if the logging is called correctly
	DateTime yesterday = yesterdayCalculator.YesterdayWithLogging(loggingMock);

	Assert.AreEqual(1, loggingMock.NumberOfMethodCalls);
	Assert.AreEqual(&quot;Executing YesterdayWithLogging&quot;, loggingMock.MethodCallArguments[0]);
}
</pre>
<h2>Sample Code</h2>
<p><a>The Code</a></p>
<h2>Links</h2>
<p><a href="http://codebetter.com/blogs/jeremy.miller/archive/2005/12/19/135757.aspx">Mock Objects and Stubs: The Bottle Brush of TDD</a><br />
<a href="http://codebetter.com/blogs/jeremy.miller/archive/2005/12/20/135800.aspx">Why and When to Use Mock Objects</a><br />
<a href="http://codebetter.com/blogs/jeremy.miller/archive/2006/01/10/136407.aspx">Best and Worst Practices for Mock Objects</a><br />
<a href="http://xunitpatterns.com/index.html">xUnit Patterns</a><br />
<a href="http://www.developertesting.com/archives/month200503/20050311-UsingMockObjectsEffectively.html">Using Mock Objects Effectively</a><br />
<a href="http://www.martinfowler.com/bliki/TestDouble.html">MF Bliki: TestDouble</a><br />
<a href="http://martinfowler.com/articles/mocksArentStubs.html">Mocks Aren&#8217;t Stubs</a><br />
<a href="http://en.wikipedia.org/wiki/Mock_object">Mock object</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Crafting Code with Test Driven Development]]></title>
<link>http://transformatorhuis.wordpress.com/2009/08/30/crafting-code-with-test-driven-development/</link>
<pubDate>Sun, 30 Aug 2009 18:57:11 +0000</pubDate>
<dc:creator>cyberroadie</dc:creator>
<guid>http://transformatorhuis.wordpress.com/2009/08/30/crafting-code-with-test-driven-development/</guid>
<description><![CDATA[I just finished doing every exercise of Agile Java: Crafting Code with Test-Driven Development by Je]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I just finished doing every exercise of <a href="http://www.amazon.com/Agile-Java-TM-Test-Driven-Development/dp/0131482394">Agile Java: Crafting Code with Test-Driven Development by Jeff Langr</a>.</p>
<p>You can find the solutions to all the exercises in <a href="http://github.com/cyberroadie/spikes/tree/master">my Git Hub repository</a>.</p>
<p>Install<a href="http://en.wikipedia.org/wiki/Git_(software)"> git (version control system)</a> and use the following comand:<br />
<code>git clone git://github.com/cyberroadie/spikes.git</code><br />
to check out the code.</p>
<p>The exercises are not indexed but I added tags (Lessonxx) for every chapter I finished. There are 3 main parts: The chess game, the exercises you can find at the end of every chapter and some exercises I did whilst reading the chapters. </p>
<p>Although Jeff did use JUnit 3 and Ant in the book, I used Maven and JUnit 4 instead.</p>
<p>Please feel free to use this code and I&#8217;m happy to receive any updates/patches/improvements <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p> Happy Coding <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Olivier</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Unit testing Python + MySQLdb warnings]]></title>
<link>http://l0b0.wordpress.com/2009/10/14/unit-testing-python-mysqldb-warnings/</link>
<pubDate>Wed, 14 Oct 2009 11:50:36 +0000</pubDate>
<dc:creator>l0b0</dc:creator>
<guid>http://l0b0.wordpress.com/2009/10/14/unit-testing-python-mysqldb-warnings/</guid>
<description><![CDATA[There seems to be several methods out there, based on elevating warnings to errors using warnings.si]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>There seems to be several methods out there, based on elevating warnings to errors using <a href="http://forums.devshed.com/python-programming-11/mysqldb-exceptions-616785.html"><code>warnings.simplefilter</code></a>. Here&#8217;s another method, based on <a href="http://docs.activestate.com/activepython/3.1/python/library/warnings.html#warning-testing">recording warnings in a variable</a>, and checking that the last one is a <code>MySQLdb.Warning</code>. Hopefully to be integrated in <a href="http://www.projecthepinspire.net/">INSPIRE</a>.</p>
<pre class="brush: python;">
import MySQLdb
import unittest
import warnings
[...]
class TestTagInsert(unittest.TestCase):
    def test_too_long_tags(self):
        with warnings.catch_warnings(record=True) as warn:
            [Run SQL statement]
            self.assert_(len(warn) == 1) # Ensures that the next statement won't break the testing
            self.assertEqual(
                MySQLdb.Warning,
                warn[-1].category
                )
            #If you also want to check the text of the warning:
            self.assert_(
                'truncated' in str(warn[-1].message))
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Pruebas unitarias usando mock objects]]></title>
<link>http://elespaciodejaime.wordpress.com/2009/10/11/pruebas-unitarias-usando-mock-objects/</link>
<pubDate>Sun, 11 Oct 2009 20:42:22 +0000</pubDate>
<dc:creator>elespaciodejaime</dc:creator>
<guid>http://elespaciodejaime.wordpress.com/2009/10/11/pruebas-unitarias-usando-mock-objects/</guid>
<description><![CDATA[Hoy comenzaré el día escribiendo un post después de casi dos meses lejos del blog, ha sido un tiempo]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Hoy comenzaré el día escribiendo un post después de casi dos meses lejos del blog, ha sido un tiempo largo pero ha sido aprovechado para aprender nuevas tecnologías e historias que compartir por aquí.</p>
<p>El tema de hoy será como escribir pruebas unitarias usando mock objects, pero, ¿qué son los mock objects? Yo los definiría como objetos programables para que se comporten de una manera determinada en runtime. ¿Y para qué puede servirnos esto al hacer pruebas unitarias? Nos servirá para probar las clases aisladas de sus dependencias, así, si una de las clases de las que nuestra clase depende falla, entonces este error no afectará la prueba unitaria de nuestra clase y deberemos identificar y solucionar ese problema en la otra clase (que debería tener escritas algunas pruebas unitarias).</p>
<p>Veamos un ejemplo en el que las depedencias pueden fallar.</p>
<p><img class="aligncenter size-full wp-image-175" title="Clases con dependencias " src="http://elespaciodejaime.wordpress.com/files/2009/10/clases_con_dependencias.png" alt="Clases con dependencias " width="550" height="280" />La clase que queremos probar es ManejoDeUsuariosImpl, una implementación de la interface ManejoDeUsuarios, ésta clase se compone de instancias de LDAPAccesibleImpl, esto significa que si algo falla en LDAPAccesibleImpl nuestra clase también fallará probablemente y al hacer pruebas unitarias lo que queremos es <strong>someter a prueba exclusivamente el comportamiento de una clase independientemente del correcto funcionamiento de sus dependencias</strong>. Para darnos una mejor idea&#8230; ¿Qué podría fallar en LDAPAccesibleImpl? Hmm creo que todo, podría fallar la conexión de red al servidor LDAP, podría suceder que hayan eliminado al usuario que pensabamos usar para nuestras pruebas unitarias, etc.</p>
<p>Bueno, veamos un ejemplo de prueba unitaria para nuestra clase ManejoDeUsuariosImpl que es la implementación de ManejoDeUsuarios.</p>
<p>ManejoDeUsuarioImplTest.java</p>
<pre class="brush: java;">
package com.imageneureka;

import org.junit.Test;

import static org.easymock.EasyMock.*;

public class ManejoDeUsuariosImplTest {

 private static final String USUARIO_ACTIVO = &#34;active&#34;;
 private static final String USUARIO_NO_EXISTENTE = &#34;inactive&#34;;

 @Test
 public void hacerAlgoConUnUsuarioActivoTestHappyPath()
 throws Exception {
 // primer paso: creamos el mock, usando el metodo
 //estatico org.easymock.EasyMock.createMock
 LDAPAccesible foo = createMock(LDAPAccesible.class);
 // segundo paso: establecemos el comportamiento
 //, parametros -&#62; respuesta
 expect(foo.esUnUsuarioActivo(USUARIO_ACTIVO)).
 andReturn(Boolean.TRUE).anyTimes();
 // invocamos replay sobre el mock
 replay(foo);
 ManejoDeUsuariosImpl bar = new ManejoDeUsuariosImpl();
 // necesitamos esta linea para establecer la instancia
 //de LDAPAccesible que usara
 // nuestra clase a probar, en este caso el mock
 bar.setMyLDAPAccesibleImpl(foo);
 bar.hacerAlgoConUnUsuarioActivo(USUARIO_ACTIVO);
 // invocamos verify sobre el mock
 verify(foo);
 }

 @Test(expected=IllegalArgumentException.class)
 public void hacerAlgoConUnUsuarioActivoTestLLamadaIncorrecta()
 throws Exception {
 // primer paso: creamos el mock, usando el metodo estatico
 //.easymock.EasyMock.createMock
 LDAPAccesible foo = createMock(LDAPAccesible.class);
 // segundo paso: establecemos el comportamiento,
 //parametros -&#62; respuesta
 expect(foo.esUnUsuarioActivo(USUARIO_NO_EXISTENTE)).
 andReturn(Boolean.FALSE).anyTimes();
 // invocamos replay sobre el mock
 replay(foo);
 ManejoDeUsuariosImpl bar = new ManejoDeUsuariosImpl();
 // necesitamos esta linea para establecer la instancia
 //de LDAPAccesible que usara
 // nuestra clase a probar, en este caso el mock
 bar.setMyLDAPAccesibleImpl(foo);
 bar.hacerAlgoConUnUsuarioActivo(USUARIO_NO_EXISTENTE);
 // invocamos verify sobre el mock
 verify(foo);
 }
}
</pre>
<p>Antes de que revisemos el ejemplo les sugiero bajarse el ejemplo completo para que puedan ver la dependencia entre las clases de implementacion y asi puedan darse una idea mas clara de qué es lo que pretende testear esta prueba unitaria.</p>
<p><a title="Ejemplo" href="http://www.2shared.com/file/8369937/d643442b/easyMockTest.html" target="_blank">http://www.2shared.com/file/8369937/d643442b/easyMockTest.html</a></p>
<p>En el archivo que bajarán encontrarán una carpeta con un archivo pom.xml, éste es el project object model de maven, para los que no conocen maven, es un manejador de dependencias y proyectos muy útil, con él solamente necesitan el pom.xml y las dependencias (jars) se bajan de internet automáticamente, además ya se está convirtiendo en el estándar para gestionar proyectos, por lo tanto: <a title="Maven tutorial" href="http://www.chuidiang.com/java/herramientas/maven.php" target="_blank">http://www.chuidiang.com/java/herramientas/maven.php</a> además tiene muy buena integración con los IDEs que conozco, a saber Netbeans y Eclipse, en Netbeans tan solo tiene que ir a instalar plugins seleccionar el plugin para maven y ya esta, listo para usar.</p>
<p>Regresando a los nuestro, en esta prueba unitaria hay dos métodos de prueba, uno de ellos (hacerAlgoConUnUsuarioActivoTestHappyPath() ) prueba la clase bajo circuntancias favorables (usuario válido) y el otro (hacerAlgoConUnUsuarioActivoTestLLamadaIncorrecta()) prueba la llamada al método ManejoDeUsuariosImpl.hacerAlgoConUnUsuarioActivo() con un usuario incorrecto, circunstancia bajo la cual éste metodo debería responder con una excepción IllegalArgumentException y el proceso de emulación del comportamiento de la dependencia de la clase a testear se detalla como comentarios en el ejemplo.</p>
<p>Por último, cabe mencionar que easyMock no es el único framework para crear mock objects, también existe JMock, el cual implementa ésta funcionalidad aunque con un estilo <a title="Domain specific languages" href="http://www.agile-spain.com/lenguajededominioespecifico" target="_blank">DSL</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Scrum: A Year in Review]]></title>
<link>http://alexhamer.ca/2009/10/06/scrum-a-year-in-review/</link>
<pubDate>Tue, 06 Oct 2009 21:06:27 +0000</pubDate>
<dc:creator>alex</dc:creator>
<guid>http://alexhamer.ca/2009/10/06/scrum-a-year-in-review/</guid>
<description><![CDATA[It was early October of last year that we took the first steps towards adopting Scrum and undertakin]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>It was early October of last year that we took the first steps towards adopting Scrum and undertaking the challenge of becoming more agile.  I figure this is a good time to review the year, the progress we&#8217;ve made, and the challenges we still have to overcome.</p>
<p><strong>Original intentions<br />
</strong></p>
<p>My original intentions with Scrum were to adopt a methodology that forced issues to the surface and gave us some flexibility in dealing with them.  Specifically, I felt: (1) my staff weren&#8217;t working together as well as they could, (2) we had serious quality issues with our applications, and (3) projects lacked visibility with the business.  I think that these were largely symptoms of underlying issues, and I hoped Scrum would allow us to bring those issues to the surface and deal with them.  So &#8230;</p>
<p><strong>How did it work out?</strong></p>
<p><em>Are my staff working better together?<br />
</em></p>
<p>Definitely.  There is a greater appreciation for each others&#8217; roles.  We&#8217;ve largely eliminated the perspective that work can be thrown &#8216;over the wall&#8217; (i.e. requirements over to development over to QA) with no interest in how others do their job.  There is a greater focus on the team and accomplishing something together.  And no one works in isolation with no understanding of what the person next to him or her is doing.</p>
<p>But we&#8217;re not quite there yet.  From my perspective we&#8217;ve come maybe 50% of how far I&#8217;d like use to go.  I&#8217;d like to see more critical thinking and discussion, and still more of a focus on the team.  I&#8217;d also like to see more thought going into and a stronger commitment to the sprint goals.  But there is no doubt in my mind that the Scrum framework can facilitate improvements in team work, and with my staff I think it will continue to do so.</p>
<p><em>Has quality improved?</em></p>
<p>We get some positive marks here, as well. Code coverage and documentation is probably five or ten times what it is in our legacy, pre-Scrum systems.  Regression bugs (i.e. those that crop up outside the execution of a story) are rare &#8212; maybe one or two a month.  As we are about to put the first piece of the system into production, I have great confidence that it should be essentially bug free.</p>
<p>But we still need our test coverage to be higher, and we need the quality of our tests to improve.  The team is still weak on Test Driven Development (TDD).  While we are making improvements, our focus on quality must continue to grow.  Again &#8230; we&#8217;ve come maybe 50% of how far we should go.</p>
<p><em>Has visibility increased?</em></p>
<p>In this area we&#8217;ve made incredible progress.  The quantification of user stories (we estimate using t-shirt sizes but I convert them to numbers) and the use of Version1 to manage our backlog have provided the project team and leadership with an unprecedented view in the project, our progress, and where we have to go.  In addition, Scrum has given us the tools to work more closely with the business, with stakeholders (not just the product owner) joining us for planning meetings and stand-ups.  I think their perspective on the work we do has changed &#8230; and just maybe become a little more sympathetic to the challenges of software development.</p>
<p><strong>My Lessons Learned</strong></p>
<p><em>Changing peoples&#8217; perspectives is hard</em></p>
<p>You can never underestimate how hard it is for people to change their perspectives.  This has been one of my biggest challenges &#8212; getting my staff to see their jobs and our systems (products) from a different perspective.  <em>My </em>perspective on their roles has certainly changed: it&#8217;s clear to me know how important it is to have staff who aren&#8217;t just coders, who can see the big picture, who have good judgment, and who take it upon themselves to learn continuously (and not just about the latest technology).</p>
<p>I have definitely seen a change in all of my staff, but I have to admit I&#8217;d like to see more.</p>
<p><em>Training is critical to make a change like this</em></p>
<p>This is an obvious one, but I&#8217;ve learned it nonetheless.  Unfortunately we undertook a change towards Scrum just as the financial crisis hit, and as a result I had very little resources to train my staff.  Specifically I would have got them training in Scrum, and at least a class on test-driven development.  I also would have liked to have money to send them to conferences (specifically the annual Agile Vancouver event).  If I were to undertake this again at a different company, a lack of sufficient training funds would be a non-starter.</p>
<p><em>Get your systems in place first</em></p>
<p>By systems I mean proper development and test environments, build servers, et cetera.   It&#8217;s been a year and we&#8217;re still building out some of the infrastructure we need to be really agile (like a proper user acceptance testing environment).  I&#8217;ve read discussions of the value of a &#8217;sprint zero&#8217;, which is used to set up all the infrastructure.  For us, we could have taken use a sprint zero through two or three to get it all set up.  It has impeded us at various levels since day one.  (Although, admittedly, we didn&#8217;t know everything we wanted or needed when we started, and some of his has been dictated by how the project has developed.)</p>
<p><em>Managing expectations is critical </em></p>
<p>Typically I&#8217;m pretty good at this, but there&#8217;s always room for improvement.  I was the one who sold Scrum internally, and in so doing established certain expectations with my bosses concerning what we could accomplish.  While I&#8217;m sure they see the value, I should have spent more time educating them on what we were doing and what they could expect from it.  I should have managed expectations better &#8212; but I was walking the fine line of selling the change enough that they&#8217;d buy in, but not so much that they&#8217;d think this would be a cure-all.</p>
<p><strong>What&#8217;s next?</strong></p>
<p>I have a few goals for the next six-to-twelve months.  As the team matures and our processes continue to stabilize, this will open up opportunities for additional improvements in how we work.</p>
<p><em>A greater focus on quality</em></p>
<p>From day one I&#8217;ve told the team that quality is non-negotiable.  That said, if everyone isn&#8217;t on the same page as to what quality means, it becomes negotiable anyway (we did define it, but there&#8217;s always room for interpretation).  We have recently improved the metrics we use and will take more proactive action with these metrics in hand to increase system quality.  This will involve some more learning within the team, and definitely some greater discipline.</p>
<p><em>Lean development</em></p>
<p>I recently read &#8220;Implementing Lean Software Development&#8221; by  Mary and Tom Poppendieck and it was awesome.  I had looked into lean concepts before, but it didn&#8217;t really seem to fit where we were as a development group (in other words I don&#8217;t think we weren&#8217;t ready for these ideas).  With a year of Scrum under our belts, now is the time to start maturing and getting a better understanding of some of the valuable ideas and practices lean offers.<em></em></p>
<p><em>Scrumban</em></p>
<p>This is related to lean development, but it involves more process changes to how we approach our work.  I see the value of continuous flow, but I don&#8217;t think the team or the company is ready to go there.  In six months, maybe &#8230; .  I definitely see this as a natural progression from where we are today.</p>
<p><em>Stepping Away</em></p>
<p>From day one I&#8217;ve acted as the ScrumMaster.  As the department director I&#8217;ve known this goes against best practices &#8212; managers shouldn&#8217;t be ScrumMasters.  Given our company culture, as well as resources we had at hand, I chose to take on this job anyway.  I think I have been reasonable successful, although I have plenty of examples of where my position has caused problems.  I will be stepping away somewhat, letting another team member take on many of the responsibilities.  I still plan to be involved from more of a coaching perspective &#8212; I probably still have the greatest technical knowledge of Scrum &#8212; but I won&#8217;t be as involved on a day-to-day basis.</p>
<p><strong>And that&#8217;s all &#8230;</strong></p>
<p>The past year my perspective on software development, team work, and project management has changed dramatically.  <em>Scrum is good</em>.</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
