<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ten Tonne Baby &#187; Process</title>
	<atom:link href="http://www.tentonnebaby.com/category/development/process/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tentonnebaby.com</link>
	<description>Discussion on Web Technologies, Design and London</description>
	<lastBuildDate>Thu, 19 Jan 2012 09:33:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Principles of BDD, and the impact on unit testing</title>
		<link>http://www.tentonnebaby.com/2010/12/19/principles-of-bdd-and-the-impact-on-unit-testing/</link>
		<comments>http://www.tentonnebaby.com/2010/12/19/principles-of-bdd-and-the-impact-on-unit-testing/#comments</comments>
		<pubDate>Sun, 19 Dec 2010 21:13:27 +0000</pubDate>
		<dc:creator>Oli</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[requirements]]></category>

		<guid isPermaLink="false">http://www.tentonnebaby.com/2010/12/19/principles-of-bdd-and-the-impact-on-unit-testing/</guid>
		<description><![CDATA[I’ve been working with BDD for a little while now in delivering a practical project, and have started to get a good sense of what is important. Initially I found that a lot of the articles and reading material made sense but were quite abstract. I agreed with the points made in a general sense, [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been working with <abbr title="Behaviour Driven Development">BDD</abbr> for a little while now in delivering a practical project, and have started to get a good sense of what is important. Initially I found that a lot of the articles and reading material made sense but were quite abstract. I agreed with the points made in a general sense, but had some questions around the actual practical application that weren’t necessarily answered. </p>
<h2></h2>
<h2>Everything pulls from the defined scenarios</h2>
<p>The main thing I like about the BDD workflow is that it gives you great structure around how to approach a project. Often when you first start something new it can be a little daunting to know where to begin – whether you start designing a schema, writing some unit tests (which tests, where do you start…), if you begin by writing up some user stories and apply an agile structure around it etc.</p>
<p>The great thing with BDD is that you are either writing some new features or scenarios using a plain English language, or you are implementing tests to deliver those scenarios. Every piece of code that you write and every test should be directly ‘pulling’ from the defined scenarios. As soon as you have finished implementing tests to prove a given scenario, you move on to the next. If you run out of scenarios, you either write some more scenarios for the current feature, or you begin defining a new feature. At any point in time, you pretty much know exactly what to do next.</p>
<h2>How does BDD affect unit tests?</h2>
<p>A big area of confusion that I initially had was how BDD affects unit testing – whether unit tests are effectively replaced by the natural language scenarios, and if you are testing more granular technical detail if you are meant to try to express this from an end user point of view with the scenarios etc.</p>
<p>A user’s experience with software is entirely based on the interactions they have with the user interface. Therefore it makes sense to define the expected behaviours from a user’s point of view, in terms of what the current situation is (Given), what action they take (When) and what the expected result is (Then). </p>
<p>It works quite well to have executable tests for these scenarios to test the user interface, and mock the dependencies. In my project this means testing the MVC controllers and action methods, but mocking the application services. Using a mocking framework you set up the expected behaviour from the dependencies in the ‘Given’ steps, the ‘When’ steps execute the action method on the controller, and the ‘Then’ steps verify things like the ActionResult and the ViewData.</p>
<p>You absolutely need unit tests to verify the behaviour of the lower level components, but the point is that the test scenarios that you write and the expected behaviours are all ‘pulling’ from the requirements in the defined BDD scenarios. If at any point you’re unsure of whether you have the correct set of test cases, you should refer back to the plain English scenarios, read through the expected behaviours, then ensure that your unit tests are set up to verify the correct thing.</p>
<p>This really means that the BDD automated acceptance tests and unit tests do both sit well together. The difference is that the BDD tests give the overall context that you’re working to, and provide a focal point about what you should be testing and why.</p>
<h2>Language used in unit tests</h2>
<p>BDD talks quite a lot about the importance of language used, and how the word ‘test’ implies checking something after the event. Unit tests are all about defining expected behaviours, so the word ‘should’ is much more appropriate. I have to admit, initially I quite seemed like a pretty unimportant distinction to me, and I didn’t quite get it. However I’m now totally convinced.</p>
<p>Previously I would have pretty much created a test fixture per class, and the unit tests names would have probably ended up being oriented around the technical implementation. For example, testing an application service might result in a test fixture called <strong>SecurityServiceTestFixture.</strong></p>
<p>I’ve taken to creating a test fixture for each action or process, then starting each unit test method with ‘<strong>Should&#8217; </strong>to express a particular facet of the expected behaviour. Using the same example, I might create a fixture called <strong>RegisteringANewUser</strong> and the unit test would be called something like <strong>ShouldSendAnEmailToVerifyTheUserEmailAddress.</strong></p>
<p>Although this is quite a subtle distinction it makes it much easier to work out what test cases there should be, and to read back through and understand exactly which behaviours are being tested. It’s also easier to read the original scenario definition, read through your unit tests and get a sense of whether everything is covered.</p>
<h2>Composition of a unit test</h2>
<p>The actual way that a unit test is put together is pretty much unaffected – you’ll generally go with the same arrange, act assert pattern. The only change that I’ve really had to make is organising the test fixtures, and the language that I use for the test methods.</p>
<h2>BDD Workflow</h2>
<p>Putting all of this together gives you the following kind of workflow…</p>
<ul>
<li>You start with the Gherkin based scenarios defined in plain English </li>
<li>You bind each scenario step to an executable method, and test your user interface </li>
<li>During this process you use interfaces for any dependencies, and mock these to verify the UI behaviour </li>
<li>Once the UI tests are passing, you look at each dependency and write lower level unit tests to cover the expected behaviours </li>
<li>For each dependency, you look at any further dependencies and write unit tests to cover these additional components </li>
<li>Work to get each unit test passing </li>
<li>If at any point you get confused about which unit test cases to write, refer back to the scenario definitions to have a clear set of requirements about the expected behaviours </li>
<li>Either move on to the next scenario, or define some more scenarios </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tentonnebaby.com/2010/12/19/principles-of-bdd-and-the-impact-on-unit-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting work on TeamBrain, an open source knowledge repository for project teams</title>
		<link>http://www.tentonnebaby.com/2010/12/14/starting-work-on-teambrain-an-open-source-knowledge-repository-for-project-teams/</link>
		<comments>http://www.tentonnebaby.com/2010/12/14/starting-work-on-teambrain-an-open-source-knowledge-repository-for-project-teams/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 21:44:22 +0000</pubDate>
		<dc:creator>Oli</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[specflow]]></category>
		<category><![CDATA[teambrain]]></category>

		<guid isPermaLink="false">http://www.tentonnebaby.com/2010/12/14/starting-work-on-teambrain-an-open-source-knowledge-repository-for-project-teams/</guid>
		<description><![CDATA[I’m increasingly finding that all of the information and knowledge that I want ready access to won’t quite fit in my head at one time. Most technical projects that I’ve worked on over the years have suffered from the same problem but amplified across a team. Typically the team will rely on the knowledge of [...]]]></description>
			<content:encoded><![CDATA[<p>I’m increasingly finding that all of the information and knowledge that I want ready access to won’t quite fit in my head at one time. Most technical projects that I’ve worked on over the years have suffered from the same problem but amplified across a team. Typically the team will rely on the knowledge of individuals, and create quite a critical dependency on key people. There are good practices which can reduce the risk of this, such as pair programming, and documenting system behaviour with automated tests, but it still helps to have instant access to pretty much anything you need to know about a project. The fundamental problem is that documentation is not much fun, and very quickly gets out of date.</p>
<p>Obviously there are solutions to this problem, the foremost being to set up a project wiki. However I’m quite fussy about design and interaction, and the way that software feels when you use it, and I’ve yet to find a wiki product that makes me feel good. I want something that is addictive and satisfying to use, that engages you and makes you want to work with it. The idea being to build a multi-tenant application that can host project knowledge for teams.</p>
<p>Based on this I’ve started work on <a href="http://teambrain.codeplex.com">TeamBrain</a>, hosted on Codeplex. Feel free to grab a copy of the source and talk to me as it develops. I have some time off work so will be trying to flesh it out over the next few weeks.</p>
<p>I’m also taking the opportunity to try out a few new technologies and things I’ve wanted to take a look at for a while. The one I’m most excited about is BDD (Behaviour Driven Design). I’ll be running the project by defining features and scenarios in <a href="http://specflow.org/">SpecFlow</a>, and having all of the unit tests and behaviour pulling from the defined scenarios. If you want to learn more, I suggest starting with <a href="http://specflow.org/specflow/screencast.aspx">this screencast</a> which gives a really great introduction. I’ll post some examples and hints as I learn along the way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tentonnebaby.com/2010/12/14/starting-work-on-teambrain-an-open-source-knowledge-repository-for-project-teams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enforcing coding standards when working with legacy code</title>
		<link>http://www.tentonnebaby.com/2010/10/17/enforcing-coding-standards-working-with-legacy-code/</link>
		<comments>http://www.tentonnebaby.com/2010/10/17/enforcing-coding-standards-working-with-legacy-code/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 17:15:52 +0000</pubDate>
		<dc:creator>Oli</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[codingstandards]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[stylecop]]></category>

		<guid isPermaLink="false">http://www.tentonnebaby.com/2010/10/17/enforcing-coding-standard-working-with-legacy-code/</guid>
		<description><![CDATA[I’ve been thinking about the best way to start getting a consistent coding style with our team. Mostly I’ve worked on new projects and this is a relatively trivial thing to do by setting up StyleCop with an agreed set of rules, and hooking it up to analyse all source files as part of the [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been thinking about the best way to start getting a consistent coding style with our team. Mostly I’ve worked on new projects and this is a relatively trivial thing to do by setting up <a href="http://stylecop.codeplex.com/">StyleCop</a> with an agreed set of rules, and hooking it up to analyse all source files as part of the Continuous Build. Along with a culture based on sarcasm and peer abuse, this usually works out fine.</p>
<p>However in this instance I’m working with a large legacy codebase. Even with the best intentions people won’t stick to a convention unless it gets enforced, and based on the amount of code that doesn’t comply it isn’t very simple to start enforcing the standard.</p>
<p>The only solution I could really see was to swallow the pain and go and reformat all of the existing code, then start enforcing analysis on the projects that have been updated.</p>
<p>I don’t think this would have even been possible if it hadn’t been for <a href="http://www.jetbrains.com/resharper/">Resharper 5</a> and the <a href="http://stylecopforresharper.codeplex.com/">StyleCop for Resharper</a> plugin. I’ve become massively more productive since using Resharper a few weeks back and in this instance it’s been simply awesome.</p>
<h3></h3>
<h2>Code Cleanup</h2>
<p>Once Resharper has been configured with the StyleCop plugin so all coding style conventions are set up, you can run the code cleanup feature against a file or folder (Ctrl-Shift-Alt-F) which will reformat all existing code based on the configured rules. In my case this will typically reduce a file from around 300 violations to about 8. You can set up a profile to control exactly what does or does not get changed as part of this process.</p>
<h2>Cycle through code issues (F12)</h2>
<p>The next most useful feature is that StyleCop violations are treated as code issues by ReSharper. Hitting F12 repeatedly within a code file will jump to the next issue making it very simple to navigate around all violations and clean them up.</p>
<h2>Violation highlighting within editor</h2>
<p>The plugin will also highlight any style violation as you code, and provide tooltips and messages in the status bar to indicate what the violation was.</p>
<p><a href="http://www.tentonnebaby.com/wp-content/uploads/2010/10/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tentonnebaby.com/wp-content/uploads/2010/10/image_thumb.png" width="562" height="257" /></a> </p>
</p>
<p>It will still take a while to finish updating the existing codebase, but I’m not even sure it would be feasible to attempt this without these tools.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tentonnebaby.com/2010/10/17/enforcing-coding-standards-working-with-legacy-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automating acceptance tests with BDD</title>
		<link>http://www.tentonnebaby.com/2010/06/19/automating-acceptance-tests-with-bdd/</link>
		<comments>http://www.tentonnebaby.com/2010/06/19/automating-acceptance-tests-with-bdd/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 11:22:37 +0000</pubDate>
		<dc:creator>Oli</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[specflow]]></category>
		<category><![CDATA[tekpub]]></category>

		<guid isPermaLink="false">http://www.tentonnebaby.com/2010/06/19/automating-acceptance-tests-with-bdd/</guid>
		<description><![CDATA[I think we’re now running a pretty well-structured agile process, but one area that I’m interested in tightening up is how to express acceptance tests for user stories, and ideally how to automate the tests. A lot of the agile reading material talks in passing about acceptance tests without any real definition of the vocabulary [...]]]></description>
			<content:encoded><![CDATA[<p>I think we’re now running a pretty well-structured agile process, but one area that I’m interested in tightening up is how to express acceptance tests for user stories, and ideally how to automate the tests. A lot of the agile reading material talks in passing about acceptance tests without any real definition of the vocabulary or approach to use in expressing, organising and executing tests.</p>
<p>This fits in very nicely with some of the ideas in Behaviour Driven Design, which is like the next iteration of thinking around TDD. The idea is to express acceptance tests using a simple DSL vocabulary working in plain English, then hook up each acceptance test scenario to some automated tests which prove the scenario works as expected.</p>
<p>A simple example would be…</p>
<p><strong>+Title: Customer withdraws cash+     <br /></strong><em>As a</em> customer,    <br /><em>I want</em> to withdraw cash from an ATM,    <br /><em>so that</em> I don’t have to wait in line at the bank.</p>
<p>In BDD, an acceptance test would be along the lines of…</p>
<p><strong>+Scenario 1: Account is in credit+     <br /></strong><em>Given</em> the account is in credit    <br /><em>And</em> the card is valid    <br /><em>And</em> the dispenser contains cash    <br /><em>When</em> the customer requests cash    <br /><em>Then</em> ensure the account is debited    <br /><em>And</em> ensure cash is dispensed    <br /><em>And</em> ensure the card is returned</p>
<p>I’ve lifted the example here from the <a href="http://blog.dannorth.net/introducing-bdd/">key article published on BDD from Dan North</a> – if you’re interested so far then you should stop reading now and go and check out the article.</p>
<p>BDD frameworks will then map each step expressed in the text above through to a method in a test class, so you have a great balance between expressing the acceptance tests in simple language, but having the ability to execute the tests.</p>
<p>I found the best way to learn about this so far was a TekPub video – you’ll need a subscription, but the video is under the ‘Concepts’ section &gt; <a href="http://tekpub.com/view/concepts/5">Concepts:5 Behaviour-driven Design with Specflow</a>.</p>
<p>Overall it seems like a more natural way to approach proving the application behaviour, and makes it much easier for testers and analysts to work alongside you in defining acceptance tests. I’m quite keen to roll this into our day-to-day process.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tentonnebaby.com/2010/06/19/automating-acceptance-tests-with-bdd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

