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

<channel>
	<title>Liz Keogh&#039;s blog &#187; testing</title>
	<atom:link href="http://lizkeogh.com/category/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://lizkeogh.com</link>
	<description>Software, Training, Coaching, Writing</description>
	<lastBuildDate>Sat, 04 Feb 2012 20:22:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Real Cost of Change</title>
		<link>http://lizkeogh.com/2012/01/30/the-real-cost-of-change/</link>
		<comments>http://lizkeogh.com/2012/01/30/the-real-cost-of-change/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 12:37:42 +0000</pubDate>
		<dc:creator>liz</dc:creator>
				<category><![CDATA[breaking models]]></category>
		<category><![CDATA[feedback]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[learning models]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://lizkeogh.com/?p=760</guid>
		<description><![CDATA[We have a strange desire for control.
I was in a planning meeting with my project manager and several of the devs. &#8220;What happened?&#8221; the project manager said. &#8220;Why did this one story take so long?&#8221;
&#8220;There was some functionality we needed and didn&#8217;t know about,&#8221; I replied. &#8220;We managed to get it in before the deadline, [...]]]></description>
			<content:encoded><![CDATA[<h3>We have a strange desire for control.</h3>
<p>I was in a planning meeting with my project manager and several of the devs. &#8220;What happened?&#8221; the project manager said. &#8220;Why did this one story take so long?&#8221;</p>
<p>&#8220;There was some functionality we needed and didn&#8217;t know about,&#8221; I replied. &#8220;We managed to get it in before the deadline, though.&#8221; The business had been quite happy with that, and they were notoriously hard to please.</p>
<p>&#8220;If they&#8217;re going to change their mind like this,&#8221; the PM replied, &#8220;we&#8217;re going to have to introduce some kind of change control.&#8221;</p>
<p>&#8220;Please don&#8217;t,&#8221; I begged. &#8220;If you do that, the business will spend more time investing in getting things right to start with.&#8221;</p>
<p>&#8220;Exactly.&#8221;</p>
<p>&#8220;But they&#8217;ll still get it wrong. No amount of planning would have spotted that missing piece before we showed it to them! When they get it wrong now, though, they&#8217;ll encounter the change control and they&#8217;ll want to spend even <em>more</em> time getting it right first time. And they&#8217;ll <em>still</em> get it wrong, but now we&#8217;ll have made it more expensive for them to be wrong. We&#8217;ll have a formal process which means it takes even longer for us to find out what&#8217;s missing, by which time us devs will have to work to remember the code and the change will take longer. It will slow us down. So they&#8217;ll see that, and spend even <em>more</em> time trying to get it right, and before you know it they&#8217;ll be planning whole projects up front.&#8221;</p>
<p>We have a word for that. It&#8217;s called <em>Waterfall</em>.</p>
<p><a href="http://imgur.com/PbhfM"><img src="http://i.imgur.com/PbhfM.png" alt="Waterfall's reinforcing feedback loop" width="80%" height="80%" /></a></p>
<p>That desire to control change creates a reinforcing feedback loop, in which the cost of change makes us want to invest up-front, which makes the change expensive later on, which makes us want to invest up-front, and so on.</p>
<p>In this case, it would have been pointless, except as a way of shifting blame and risk back to the analysts (and this was an internal project). The cost of change was quite low; we had clean code with a good suite of tests. It was only the cost of <em>discovery</em>, and the implementation that followed, that was really expensive.</p>
<h3>Don&#8217;t confuse the cost of discovery with the cost of change.</h3>
<p>Discovering something later on only costs more than planning for it if you&#8217;ve made a <em>commitment</em> to something else.</p>
<p>In fact, if you don&#8217;t plan for it, it can cost less. The newly-discovered knowledge will be fresh in everyone&#8217;s minds. Because the ideas haven&#8217;t been known for long, nobody&#8217;s mentally committed to them either, which makes them easier to question and clarify.</p>
<p>This is even more important when there&#8217;s a chance that the analysis might be wrong (and there&#8217;s always that chance; we learnt this from Waterfall). If you plan for something that you later have to revert, you&#8217;ve introduced a cost of change right there. Perhaps the cost is just changing some documents. Perhaps the developers have designed for the plan, and built on top of the thing which needs changing.</p>
<p>But we need to do <em>some</em> planning, right? Otherwise the chances of us being wrong and building on top of the wrong thing are even bigger, and there&#8217;s even more chance that we&#8217;ll have made commitments the wrong way. So how should we plan?</p>
<p>I&#8217;ve got few more guidelines I&#8217;d like to share. Here&#8217;s the first:</p>
<h3>Keep the cost of change low.</h3>
<p>This is more important even than planning, because there&#8217;s <em>always</em> a chance that we&#8217;ll get something wrong.</p>
<p>This is what we&#8217;re aiming for: the ideal, low cost of change on an Agile project.</p>
<p><a href="http://imgur.com/XfR4U"><img src="http://i.imgur.com/XfR4U.png" alt="The wonderfully low cost of change on a very nice Agile project." width="80%" height="80%" /></a></p>
<p>The first thing to notice about this is that the cost of change is <em>not zero</em>. That&#8217;s going to become important in the next section, and it&#8217;s what drives the team&#8217;s desire for change control and starts kicking off that Waterfall loop.</p>
<p>The second thing to notice is that this bears little resemblance to actual, real Agile projects.</p>
<p>On a real Agile project, it&#8217;s likely that we have fluctuating levels of stress, concentration, experience and desire for feedback. All of these &#8211; or lack of them &#8211; will lead us to occasionally write code that is, shall we say, less than ideal.</p>
<p>It takes discipline to write code that&#8217;s easy to change. On a real Agile project, we tend not to do it all the time. Oh, we might <em>say</em> we do, but we don&#8217;t. Not always. And if we do, our team-mates don&#8217;t. The real skill isn&#8217;t in writing clean code &#8211; it&#8217;s in cleaning up the horrible mess we made the week before. And it takes <em>even more discipline</em> to do it afterwards, especially if you&#8217;re under pressure to just hack the next working thing in too.</p>
<p><a href="http://imgur.com/A7vgE"><img src="http://i.imgur.com/A7vgE.png" alt="The real cost of change on an Agile project, showing how we clean up after ourselves." width="80%" height="80%" /></a></p>
<p>If we don&#8217;t clean up and keep that cost of change low, we&#8217;re making a commitment to the wrong thing. The longer that commitment stays in place, the higher the cost of change will become. We&#8217;ll find ourselves on that Waterfall cost of change curve, and the longer we&#8217;re on it, the more expensive it is.</p>
<p>I&#8217;ve found the skill to clean up afterwards is even more important in high-learning projects, where a lot of the technology or domain is new, at least to the team. There&#8217;s no point in writing tests up front for a class when you don&#8217;t even know what&#8217;s possible, or what other frameworks and libraries will do for you, or what the business really want. In those environments, rather than TDD or BDD, teams tend to <em>Spike and Stabilize</em>. The spikes aren&#8217;t really prototypes &#8211; they&#8217;re small pieces of features, often with hard-coded data behind them, designed to get some feedback about techology or requirements. <a href="http://dannorth.net/2011/01/15/on-craftsmanship/">Dan North, who gave me the term,</a> might write more about this later if we ask nicely, but for this post, we can simply bear in mind that the skill to stabilize later &#8211; ensuring that the cost of change is <em>lowered</em> &#8211; is often more important than the skill to keep the cost of change low up-front.</p>
<p>Because we get it wrong too.</p>
<h3>Assume you got it wrong.</h3>
<p>Human beings are hard-wired to try and get things right, and to pretend that they did even when they didn&#8217;t. I love <a href="http://en.wikipedia.org/wiki/List_of_cognitive_biases">this list of cognitive biases on Wikipedia</a>. These are just some of the ways in which we get it wrong and don&#8217;t even notice.</p>
<p>If we assume that we got it wrong, then we start to look for <em>feedback</em>, and quickly. This is difficult for most human beings. We much prefer to get validation than feedback; to be told that we did it right, rather than finding out what we did wrong. Our brain gives us these little kicks of nice chemicals when we learn that we did something right, and it feels much better than the other kind.</p>
<p>If we can remember, though, that we probably got it wrong, our focus will change. Instead of trying to invest in good requirements and nice code, we&#8217;ll try to find out what we got wrong in the things we&#8217;ve already done. Of course, we need to invest in stabilizing what we&#8217;ve done, or the cost of change goes up, and that will make it more expensive later if we find out we were wrong, which is the assumption we were trying to make in the first place&#8230; ah, the paradox!</p>
<p>There&#8217;s a fine balance to be struck between getting quick feedback &#8211; often itself an expensive proposition, given the business of most domain experts &#8211; and getting it right up front. So where does the balance lie?</p>
<h3>Don&#8217;t sweat the petty stuff.</h3>
<p>If it&#8217;s easy to change, don&#8217;t worry about it. Analysts, learn what&#8217;s easy to change. Typos, colours, fonts, labels, sizes, placement on the screen, tab order, an extra field&#8230; these are all usually easy to change, and do not normally need to be specified up-front. Even if you have a particular style you want to see on a page or form, this can usually be abstracted out and changed later &#8211; just let the devs know that you want that consistency at some point.</p>
<p>It&#8217;s more important for us to know the rough shape of what you want to see, and the flow and process of that information. We don&#8217;t want to know every field on an order item. We just want to know that it needs to be sent to the warehouse and stored locally because you&#8217;re going to check the money in the till and count the stock. The fine detail of that is pretty easy to change, so we can get feedback on it later. Getting the fine detail right would definitely be an investment, and we might have got the big picture wrong.</p>
<h3>Deliberately discover things you&#8217;ve never done before.</h3>
<p><a href="http://dannorth.net/2010/08/30/introducing-deliberate-discovery/">Dan North wrote an excellent post on Deliberate Discovery</a>, and I&#8217;ve been using it to manage risk on my projects for a while now. It&#8217;s one of the most important tools in my toolbox, along with Real Options to which it&#8217;s strongly related, so I want to cover how I use it here.</p>
<p>I really like using <a href="http://en.wikipedia.org/wiki/Cynefin">Cynefin</a> to help me work out what to target for discovery. We treat a lot of software as if it&#8217;s <em>complex</em>, and we talk about self-organising teams and high learning environments, but in reality there are huge chunks in most applications which follow well-established rules, have been done a thousand times before and probably have libraries or third-party apps to do the job for you. They&#8217;re not complex. They&#8217;re <em>complicated</em>. They require the application of a bit of expertise, and are likely to be done right and never changed again. User registration and logging in are great examples of this. You don&#8217;t need a big, thick document to describe them. The fine details might change, of course, but we already know not to sweat the petty stuff.</p>
<p>It is <em>OK to plan some aspects of a system as if it&#8217;s Waterfall</em> &#8211; for instance, deciding up-front whether you want to use your own login or let Google authenticate. Even better than requirements documents, and quicker, is to say, &#8220;It&#8217;s user registration. Make it work like Twitter&#8217;s, but we also need the user&#8217;s loyalty card number. We should offer to send them a card if they don&#8217;t have one.&#8221; Dan North calls this pattern &#8220;Ginger Cake&#8221; &#8211; it&#8217;s like a chocolate cake, but with ginger. He <em>even cuts and pastes code</em>. And it&#8217;s OK! Honestly, it is! This code is also absolutely prime for TDDing &#8211; if you actually have to write it yourself, that is, since it&#8217;s been done before so someone&#8217;s probably written something to do it for you already. You can also give this code to junior devs, for whom it&#8217;s new, and guide them in TDDing, making it perfect pair-programming territory. Everything you have ever been told about Agile software development applies particularly in this place.</p>
<p>Fortunately, most applications have a minimum set of requirements that they share with other, similar applications. David Anderson calls these <em>commodities</em> &#8211; table stakes that you have to have just to play the game &#8211; so *most* code in an application will end up going this way.</p>
<p>The places in which we&#8217;re most likely to get it wrong, and need fast feedback, are places where we&#8217;re doing something <em>new</em>. They might be technological, particular to a domain, or just things that the team themselves have never looked at. My favourite book for understanding risk is <a href="http://www.amazon.com/Waltzing-Bears-Managing-Software-Projects/dp/0932633609/">&#8220;Waltzing with Bears&#8221;</a>, which starts the first chapter with, &#8220;If a project has no risks, don&#8217;t do it.&#8221; It&#8217;s these new, risky aspects of the project that differentiate it from others and make it valuable in the first place!</p>
<p>For new and risky aspects of a project, the best thing to do is assume you got it wrong, and work out how quickly you can get feedback on how wrong you are.</p>
<h3>Any new or unknown aspect of a project will need to be changed.</h3>
<p>I was chatting to one of our analysts. &#8220;I can see this feature is in analysis at the moment,&#8221; I said. &#8220;Does that mean it&#8217;s the next thing we want the developers to do?&#8221;</p>
<p>&#8220;Oh, no,&#8221; the analyst said. &#8220;It&#8217;s only there because the analysis is quite complex. It&#8217;s all new stuff, so we&#8217;re having to be careful with it and it&#8217;s taking a bit of time. Once we get the analysis done, the development should be very easy, so we&#8217;ll do it later.&#8221;</p>
<p>&#8220;Oh, the development will be easy, I&#8217;m sure&#8230; but wouldn&#8217;t you like to find out what you did wrong now, rather than later, while it&#8217;s still fresh in your mind?&#8221;</p>
<p>The analyst smiled. The company was very much more used to Waterfall, and the idea that it was OK to get it wrong was something very new.</p>
<p>It&#8217;s OK to get it wrong, as long as you get feedback quickly, while the cost of change is still low. By working out which parts of a project are unknown or new, and targeting those <em>first</em>, we make small investments while the cost of change is still low.</p>
<h3>Keep your options open &#8211; do the risky stuff first and keep tech debt low.</h3>
<p>Anyone who&#8217;s run into me at conferences will know how much I love Real Options, and it&#8217;s really at the heart of the cost of change.</p>
<p>The only reason change costs more is because of the <em>commitment</em> that we already made. Chris Matts describes technical debt as an &#8220;unhedged call option&#8221;. <strong>Edit:</strong> while Chris came up with the metaphor, it was <a href="http://www.higherorderlogic.com/2010/07/bad-code-isnt-technical-debt-its-an-unhedged-call-option/">Steve Freeman</a> who described it. He says, &#8220;You give someone the right to buy Chocolate Santas from you at 30 cents each. That&#8217;s fine, as long as the price of chocolate stays low. As soon as it goes up, you still have to pay to make the Santas, and now you&#8217;re in trouble and your company is going bust, because you didn&#8217;t give yourself the option to get the chocolate somewhere else.&#8221;</p>
<p>Similarly, technical debt is absolutely fine until we&#8217;re called on to act, and act fast. At that point, we&#8217;re in trouble. This is the biggest reason for keeping the cost of change low &#8211; because it gives us the option for change, later. It&#8217;s a frequently-cited reason for replacing legacy projects &#8211; and, bizarrely, often forgotten when the pressure mounts and the business want their replacement app.</p>
<p>This isn&#8217;t helped by <a href="http://dannorth.net/2009/07/01/the-perils-of-estimation/">common practices of estimation and the associated promises</a>, which often lead to that pressure building up in the first place. Rather than making these promises up-front, why not try the risky bits first? I often hard-code data so that I can get feedback on a new UI early, or I spike something out using a new library or framework, or connect to that third-party application just to see what the API is really like to use, or have a chat with the team writing that other system we&#8217;re going to need in June, so I can find out how communicative and receptive to feedback they are. Doing this means that we give ourselves the most time to recover from any unexpected discoveries, and we can worry about the more predictable aspects of a system later.</p>
<p>Once we&#8217;ve got spikes out of the way, adding tests to act as documentation and examples for any legacy code we&#8217;ve created, cleaning it up so it&#8217;s self-commenting, ensuring that architectural and modular components are properly decoupled, etc., all help us to <em>stabilize</em> the code. At the same time, the effort involved in creating stable code is itself an investment. If there&#8217;s a good chance that the code might be wrong, it could be worth getting feedback on <em>that</em> &#8211; knocking up integration tests, showing it to the business, testing it, getting it live &#8211; before it&#8217;s made stable.</p>
<p>That way, the commitment made is small, and the cost of change is low.</p>
<p>Just remember to clean up and keep it that way!</p>
<p><strong>Update:</strong> Dan is currently writing about <em>Spike and Stabilize</em> and <em>Ginger Cake</em> as part of his &#8220;Patterns of Effective Delivery&#8221;. If you&#8217;re interested in finding out more, you might like to watch his <a href="http://vimeo.com/24681032">Roots talk</a> on the topics.</p>
]]></content:encoded>
			<wfw:commentRss>http://lizkeogh.com/2012/01/30/the-real-cost-of-change/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>ATDD vs. BDD, and a potted history of some related stuff</title>
		<link>http://lizkeogh.com/2011/06/27/atdd-vs-bdd-and-a-potted-history-of-some-related-stuff/</link>
		<comments>http://lizkeogh.com/2011/06/27/atdd-vs-bdd-and-a-potted-history-of-some-related-stuff/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 20:03:27 +0000</pubDate>
		<dc:creator>liz</dc:creator>
				<category><![CDATA[bdd]]></category>
		<category><![CDATA[business value]]></category>
		<category><![CDATA[stories]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://lizkeogh.com/?p=679</guid>
		<description><![CDATA[Another question that people often ask around or to me is, &#8220;What&#8217;s the difference between Acceptance Test Driven Development and Behavior Driven Development?&#8221;
To explain, I&#8217;ll go back to the time when I first learnt BDD.
BDD started at a unit or class level
Dan North started doing BDD at a unit or class level, as a replacement [...]]]></description>
			<content:encoded><![CDATA[<p>Another question that people often ask around or to me is, &#8220;What&#8217;s the difference between Acceptance Test Driven Development and Behavior Driven Development?&#8221;</p>
<p>To explain, I&#8217;ll go back to the time when I first learnt BDD.</p>
<h3>BDD started at a unit or class level</h3>
<p>Dan North <a href="http://dannorth.net/introducing-bdd/">started doing BDD at a unit or class level</a>, as a replacement for TDD &#8211; a mechanism for describing the behaviour of code and providing examples, without using the word &#8220;test&#8221;, because it turned out that this clarified a lot of the confusion (and I still find it much easier to teach TDD if I avoid the word &#8220;test&#8221;, whatever I subsequently call it).</p>
<p>It was only when Chris Matts said, &#8220;That looks quite a lot like analysis,&#8221; that Dan began taking it out to describe the behaviour of whole systems of code.</p>
<h3>ATDD practices at the time weren&#8217;t all that solid</h3>
<p>When I came across BDD (late 2004), I was working on a project which had been driven quite heavily with ATDD &#8211; at least to start with.</p>
<p>This project had 160 acceptance tests. They all consisted of lists of text boxes, button clicks, locating more text boxes and repeating until a particular outcome was reached. They were lengthy. They were rigorous. Unfortunately, at some point someone had introduced a dialog box into the flow, disrupting about 30% of these tests. There were another 10% also failing, possibly for similar reasons.</p>
<p>It took a couple of days for two of us to work through them, fixing the tests. We got most of them working, but not enough for anyone to actually care about them. The acceptance tests were making things hard to change.</p>
<h3>BDD changed the landscape</h3>
<p>Dan has since said that JBehave was &#8220;just a thought experiment&#8221;, and he didn&#8217;t really expect anyone to use it. (That&#8217;s good, because it JBehave 1.0 was pretty unusable, at least at a scenario level). It worked as a thought experiment, though, and lots of people started doing ATDD in a very different way &#8211; creating examples of how their system worked, and using those examples to explore the scope of their systems as well as the responsibility of their classes. Lots of people started working <em>outside-in</em>, from the UIs through which users experienced the system&#8217;s behaviour, to the controllers, the domain models, the utility classes, services, repositories, etc., until they finally had working software that tended to matter more to the stakeholders of the project than software had before.</p>
<p><a href="http://blog.davidchelimsky.net/2007/10/21/story-runner-in-plain-english/">Dave Chelimsky&#8217;s movement over to plain text</a> really helped this movement to take off. When people think of &#8220;BDD&#8221; they often think of the frameworks which have copied this (<a href="http://cukes.info/">Cucumber</a> and <a href="http://jbehave.org">JBehave 2.0</a> amongst them), even though <a href="http://lizkeogh.com/2011/03/04/step-away-from-the-tools/">this isn&#8217;t the complete story</a>. They have certainly encouraged developers &#8211; famous for their introverted natures &#8211; to boldly go into the analysis space.</p>
<h3>BDD enabled conversation</h3>
<p>Whether through frameworks, DSLs or just conversation, the biggest difference between BDD and ATDD was the way in which BDD enabled a common language between users and business stakeholders, because it <a href="http://domaindrivendesign.org/library/north_keogh_gitlevich_2007">supports Domain Driven Design&#8217;s &#8220;ubiquitous language&#8221;</a> (forgive the rabbit-in-the-headlights look, it was my first ever video!), and provides its own ubiquitous language for software development &#8211; the language of examples and behaviour, rather than tests and acceptance criteria.</p>
<p>The second difference was the reusability of steps. This is something which a lot of BDDers are still struggling with, so we&#8217;ve still got a way to go here. (More on steps and business / system capabilities some other time).</p>
<h3>BDD doesn&#8217;t just stop at scenarios, it goes all the way to the project vision</h3>
<p>Finally, Chris Matts introduced <a href="http://www.infoq.com/articles/pulling-power">Feature Injection</a>, which takes BDD&#8217;s patterns all the way into the analysis space.</p>
<p>(I consider Feature Injection and BDD to be children of <a href="http://dannorth.net/">Deliberate Discovery</a> (even though they preceded it), which is itself a child of <a href="http://www.infoq.com/articles/real-options-enhance-agility">Real Options</a>. I summarise Deliberate Discovery as the act of wilfully addressing ignorance. Both Deliberate Discovery and Real Options have implications and uses beyond software development, and I heartily recommend coaches and managers to go read up on them. In fact, everyone who lives a life of any kind of uncertainty should go and read up on them. And if your life is staid and comfortable, maybe it will help you to step into those challenging spaces. Go do it anyway.)</p>
<h3>Or at least, this used to be the difference&#8230;</h3>
<p>So that&#8217;s the past. What about now?</p>
<p>Well, most people who do ATDD nowadays use the Given-When-Then template which Chris introduced (shout-out to <a href="http://gojko.net/">Gojko Adzic</a> for his work in this space). They use domain language in conversation with the business. They&#8217;re interested in discussing what software would actually make a difference, then capturing that and sometimes automating it, with a focus on working out the software which would matter.</p>
<p>I&#8217;m guided by <a href="http://groups.google.com/group/behaviordrivendevelopment/msg/ee750a218b514946">Dan&#8217;s words to the BDD Google Group</a>, which apply both to TDD and ATDD:</p>
<blockquote><p>I think you can over-think these things.<br />
I&#8217;d like to avoid &#8220;BDD is better than TDD because&#8230;&#8221; or even &#8220;BDD is<br />
different from TDD (as originally envisioned) because&#8230;&#8221; </p>
<p>TDD is amazing. Its initial conception was to solve exactly what I&#8217;ve been<br />
trying to do with BDD. Originally it was described as variable scope (i.e.<br />
covering both the space of modern day TDD-in-the-small and what the ATDD/SBE<br />
folks are doing in the functional testing space). It&#8217;s not the *only* way to<br />
come up with good design, and neither is BDD. They&#8217;re just both useful to<br />
have in your back pocket as you go around trying to write decent software to<br />
solve useful problems. </p></blockquote>
<h3>They&#8217;re called different things</h3>
<p>The difference is that one is called Behaviour Driven Development &#8211; and some people find that wording useful &#8211; and one (or two) is called (Acceptance) Test Driven Development &#8211; and some people find that wording useful in a different way.</p>
<h3>And that&#8217;s it.</h3>
]]></content:encoded>
			<wfw:commentRss>http://lizkeogh.com/2011/06/27/atdd-vs-bdd-and-a-potted-history-of-some-related-stuff/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Step Away from the Tools</title>
		<link>http://lizkeogh.com/2011/03/04/step-away-from-the-tools/</link>
		<comments>http://lizkeogh.com/2011/03/04/step-away-from-the-tools/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 14:51:36 +0000</pubDate>
		<dc:creator>liz</dc:creator>
				<category><![CDATA[bdd]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://lizkeogh.com/?p=649</guid>
		<description><![CDATA[This may seem odd coming from someone who spent months coding a BDD tool, but seriously&#8230; put it down.
Step away.
BDD has taken off in the last few years, and lots of people have approached me for help. Many of the questions I get are along these lines:

These don&#8217;t seem worded quite right. What do you [...]]]></description>
			<content:encoded><![CDATA[<p>This may seem odd coming from someone who spent months coding a BDD tool, but seriously&#8230; put it down.</p>
<p>Step away.</p>
<p>BDD has taken off in the last few years, and lots of people have approached me for help. Many of the questions I get are along these lines:</p>
<ul>
<li>These don&#8217;t seem worded quite right. What do you think?</li>
<li>How can we stop these scenarios being so brittle?</li>
<li>How do we use our BDD tool to do &lt;this kind of testing&gt;?</li>
<li>We&#8217;re using a BDD tool. How do we get our analysts to help us?</li>
<li>How can we avoid all this duplication in our scenarios?</li>
<li>What do we do if the business aren&#8217;t interested in BDD?</li>
</ul>
<p>Don&#8217;t start with BDD, and definitely don&#8217;t start with the tools.</p>
<p>Start by having conversations, engaging both testers and business stakeholders or their proxies (analysts are good here). If you can&#8217;t have those conversations, stop. You can&#8217;t do BDD. You might be able to write some scenarios or some acceptance tests, but they&#8217;re likely to be brittle and it&#8217;s unlikely that anyone will be interested. Here&#8217;s why.</p>
<h3>BDD is focused on discovery.</h3>
<p>Dan wrote a <a href="http://dannorth.net/2010/08/30/introducing-deliberate-discovery/">blog post</a> introducing Deliberate Discovery some time ago. This philosophy is at the heart of BDD. There are things about your domain that you don&#8217;t know, or you&#8217;ve misunderstood, or that nobody&#8217;s thought of yet. By talking through examples in groups, the chances of uncovering these gaps and misunderstandings is increased. BDD provides a language &#8211; &#8220;Given &lt;a context&gt;, when &lt;an event happens&gt; then &lt;an outcome should occur&gt;&#8221; &#8211; which helps to prompt questions around whether the scenarios are accurate. It&#8217;s meant to help you have conversations, not replace those conversations entirely.</p>
<h3>Conversations help us discover things.</h3>
<p>You don&#8217;t have to stick to the BDD format to have those conversations. The language is a guide, and serves well for automation. Chances are that if you can&#8217;t phrase your discoveries in that way, you won&#8217;t be able to test the understanding later (though you might be able to explore some more). This is because tests start from a particular context, perform some events and verify some outcomes.</p>
<p>There are other things than scenarios which you can discover through conversations, though. You can listen to the language which your business stakeholders use. You can ask questions about the words they use and gain an understanding of the domain, which may not be used right now but will help you design your code in a way which allows changes to be made more easily, later.</p>
<p>The conversations often help to engender trust between stakeholders and the development team. When someone indicates that he wants to understand me, and plays back that understanding to check its accuracy, I am reassured that he genuinely cares. I tend to be more patient in my explanations, more likely to come join him in his place, wherever it is, and more likely to check back later to see how he&#8217;s doing.</p>
<p>Business stakeholders are just the same, only busier, and harder to get hold of. But that&#8217;s why they call it business.</p>
<h3>BDD isn&#8217;t the only way to do testing.</h3>
<p>In fact, BDD isn&#8217;t even really about testing. It&#8217;s just a way of capturing those conversations which happens to provide some tests, and lifts some of the burden on the testers. If you want to run additional performance tests, exploratory tests, or even record some tests, it doesn&#8217;t have to come under the BDD banner. It&#8217;s perfectly OK to do BDD <em>and</em> test things as well.</p>
<h3>BDD isn&#8217;t about the tools.</h3>
<p>You don&#8217;t need BDD tools to do BDD. A few of the projects I&#8217;ve been on now have run up a small DSL which they found perfectly easy to maintain. The only reason to use English-language BDD tools is because it helps to engage people who can&#8217;t read code (and I&#8217;ve seen senior business stakeholders perfectly happy with code-based DSLs before).</p>
<p>Natural-language BDD tools introduce another level of abstraction. They make scenarios harder to maintain. They can introduce ambiguity. If they don&#8217;t have auto-completion, it&#8217;s hard to see what steps are already in play. It&#8217;s even harder to see what steps can be deleted, and don&#8217;t need to be maintained. Don&#8217;t use natural-language BDD tools unless they give you significant other benefits. You can capture scenarios from conversations just as easily on an index card.</p>
<h3>Write fewer scenarios.</h3>
<p>Most of your code will be covered by just a few scenarios along the lines of, &#8220;Normally everything works like this, and then in this context it behaves unexpectedly, like <em>this</em>.&#8221; Use those tricky scenarios to cover the normal behaviour wherever possible, and focus on making sure that the code is well-designed.</p>
<p>Another way to make scenarios maintainable is to make sure that the steps are phrased at a very high level.</p>
<p>Higher than that.</p>
<p>If your scenario starts with &#8220;When the user enters &#8216;Smurf&#8217; into &#8216;Search&#8217; text box&#8230;&#8221; then that&#8217;s far too low-level. However, even &#8220;When the user adds &#8216;Smurf&#8217; to his basket, then goes to the checkout, then pays for the goods&#8221; is also too low-level.</p>
<p>Think about the capabilities of your business. What does it allow your users to do? What value do the stakeholders get from it? How does it actually make money?</p>
<p>You&#8217;re looking for something like, &#8220;When the user buys a Smurf.&#8221; Now you&#8217;ve got the money, what differentiates your business from everyone else&#8217;s? Do you advertise other Smurf-related products? Find everyone who&#8217;s bought a Smurf and show what else they bought? Offer discounts for Smurf holidays?</p>
<p>By thinking about the capabilities of the system and the goals of the business stakeholders, you&#8217;ll find ways to phrase scenarios which keep them maintainable, no matter how the GUI changes. The conversations you have will help you to identify those capabilities and goals.</p>
<p>The rest of scenario maintainability is mostly about removing duplication. Separate steps into particular concerns, like &#8220;admin&#8221;, &#8220;browsing&#8221; or &#8220;purchasing&#8221;. Put screens or pages into their own objects (thank you Simon Stewart and <a href="http://google-opensource.blogspot.com/2009/05/introducing-webdriver.html">WebDriver</a>). If you find your scenarios are getting unmaintainable, pay them the same kind of love you&#8217;d pay your code. They&#8217;ll probably be around longer.</p>
<h3>Assume you got it wrong.</h3>
<p>Part of the Deliberate Discovery ethos is that there is always something we don&#8217;t know we don&#8217;t know &#8211; second order ignorance. No matter how many scenarios we have, our understanding can <em>still</em> be wrong. The only way to discover this is to get feedback. Showcase what you&#8217;ve produced. Ask people to use the system and see how it feels. The earlier you can do this, the quicker you&#8217;ll discover that there&#8217;s no silver bullet. You will never get everything right &#8211; even if you analyse everything up-front, Waterfall style &#8211; and BDD is no exception.</p>
<p>Have enough conversations to know how to get started. Find out where the riskiest bits are, and where the system behaves unusually. Chat. Discuss. Discover. Work out how, and when, you&#8217;re going to get feedback on the work you&#8217;re about to do.</p>
<p>Then, and only then, reach for the tools.</p>
]]></content:encoded>
			<wfw:commentRss>http://lizkeogh.com/2011/03/04/step-away-from-the-tools/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Giving effective feedback: How to change your Code&#8217;s behaviour</title>
		<link>http://lizkeogh.com/2010/12/02/giving-effective-feedback-how-to-change-your-codes-behaviour/</link>
		<comments>http://lizkeogh.com/2010/12/02/giving-effective-feedback-how-to-change-your-codes-behaviour/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 16:52:19 +0000</pubDate>
		<dc:creator>liz</dc:creator>
				<category><![CDATA[bdd]]></category>
		<category><![CDATA[humour]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://lizkeogh.com/?p=617</guid>
		<description><![CDATA[Have you ever wanted to change the behaviour of some code that you work with?
I&#8217;d like to share a few techniques with you which have helped me to change the behaviour of code I&#8217;ve worked with, with little conflict, great success and positivity all round.
Imagine a legacy system who&#8217;s been in the job for five [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to change the behaviour of some code that you work with?</p>
<p>I&#8217;d like to share a few techniques with you which have helped me to change the behaviour of code I&#8217;ve worked with, with little conflict, great success and positivity all round.</p>
<p>Imagine a legacy system who&#8217;s been in the job for five years and can&#8217;t see the problem with the way he&#8217;s behaving.</p>
<p>Imagine a class, who feels like he needs to be in control of everything, and can&#8217;t delegate or trust other classes effectively.</p>
<p>Imagine a service who&#8217;s overloaded, doing the job of three systems that no longer perform, but who just heroically accepts all the work and never gives any signal that he&#8217;s about to collapse, again.</p>
<p>We&#8217;ve successfully used these techniques to help change our codebases, our systems, our services and our applications, as well as our people. I&#8217;d like to share these simple guidelines with you, based on the sandwich model of feedback. They are:</p>
<ul>
<li> Start with the right mindset </li>
<li> Anchor the things you value </li>
<li> Avoid labelling </li>
<li> Use examples </li>
<li> Work towards a bright future </li>
</ul>
<h3>Start with the right mindset</h3>
<p>There are lots of reasons we might want to change our code. I&#8217;ve seen people work on code</p>
<ul>
<li>because it doesn&#8217;t work the way they expect</li>
<li>because it&#8217;s annoying</li>
<li>because it refuses to do something which isn&#8217;t really its responsibility anyway</li>
<li>because it&#8217;s fun and powerful to change code for the sake of it.</li>
</ul>
<p>I believe there are only two good reasons to change code:</p>
<ul>
<li>to reinforce valuable behaviour</li>
<li>to increase effectiveness.</li>
</ul>
<p>If you&#8217;re not approaching the code with one of these mindsets, stop. How much do you actually respect the code you&#8217;re about to change? All code wants to do a job effectively. No code is perfect. Remember that time when you first wrote code? You were learning, too. If you can approach the code with an appreciation for the things it does right, and build on those, you&#8217;re more likely to meet with success.</p>
<p>As an example, I had one piece of code which controlled the registration of pets. I really wanted this controller to broadcast a pet&#8217;s registration, but instead of communicating asynchronously, the controller was insisting that anyone who requested the registration of a pet hung around, waiting.</p>
<p>Unfortunately, one of the people who requested pets was the GUI &#8211; an extremely important class with a lot of other jobs to do too!</p>
<p>The code was frustrating me so much that I almost got rid of him and replaced him with someone else&#8230; but then I thought about it, and remembered that apart from the fractious relationship with the GUI, the controller had been doing his job very well. This respect allowed me to change the code&#8217;s behaviour instead of replacing him.</p>
<h3>Anchor the things you value</h3>
<p>Once you have an appreciation of the value of the code, make sure that the code knows. Reinforce this. You can call out specific examples of times when the code has done something well.</p>
<p>I told my controller, &#8220;I appreciate the way in which you register pets, and the effective way you delegate to the repository. Here&#8217;s an example. I registered a new rabbit, Snowy. I gave you his date of birth, his breeder and the price I wanted to sell him for, and when I verified it with the repository later, I found that you&#8217;d passed the information on very well. This is important to me.&#8221;</p>
<p>I tend to use a unit testing framework and perhaps a mocking framework &#8211; Moq or mockito &#8211; to translate these conversations into the language of the code.</p>
<p>If it&#8217;s a whole team whose behaviour needs to change &#8211; perhaps an entire application &#8211; then I&#8217;ll get everyone together and talk about the things that the entire team does well. For this, I use scenarios, either with a DSL or perhaps a BDD tool like Cucumber or JBehave. Automation tools like Selenium or WiPFlash let me translate my feedback into something they understand.</p>
<p>By anchoring the things that I value about the code, I can change his behaviour without fear that he&#8217;ll change in ways I <em>didn&#8217;t</em> want.</p>
<h3>Avoid labelling</h3>
<p>There are two types of labelling that I avoid: negative labelling, and pattern labelling.</p>
<p>Once I was judging a competition in which a coder announced, &#8220;This code is shite!&#8221; I marked him down. &#8220;If any other coder hears you say that,&#8221; I said, &#8220;they&#8217;ll either be wary of trying things out or they&#8217;ll think it&#8217;s OK to start devaluing other people&#8217;s code.&#8221; Labelling code negatively this way can be damaging for everyone involved in the project, <em>even if you wrote the code</em>.</p>
<p>Labelling code by calling out the patterns of behaviour can also be unhelpful. I remember one piece of code that got labelled as a &#8220;Visitor&#8221;. From then on, everyone expected it to behave like a Visitor. No matter what its responsibilities were, coders expected it to behave like a Visitor and encouraged the other classes in the system to do the same. Eventually the code broke down so badly that we had to replace it altogether, just because we had labelled it badly.</p>
<h3>Use examples</h3>
<p>We already looked at how to use examples to anchor positive behaviour instead. We can also use examples to show the difference between the behaviour we want, and the behaviour we&#8217;ve actually got.</p>
<p>&#8220;Instead of watching the repository,&#8221; I told the controller, &#8220;I&#8217;d like you to listen to him instead, and trust him more. Sometimes the repository might give you a message. I&#8217;d like you to respond to that message.&#8221;</p>
<p>&#8220;How long do you want me to wait after saving to get the message?&#8221; the controller asked.</p>
<p>&#8220;Don&#8217;t wait,&#8221; I told him. &#8220;Instead of telling me it&#8217;s done, I&#8217;d like you to tell me that it&#8217;s in progress instead. Let&#8217;s say that the repository takes five seconds. You should be responding in less than one.&#8221; We used some threading to illustrate how the repository might go off and do its job, and talked through the example in the controller&#8217;s language until I knew he understood.</p>
<h3>Work towards a bright future</h3>
<p>By focusing on the positive goals we want to achieve, we don&#8217;t really have to spend much time on the negative aspects of the code&#8217;s behaviour. After the examples were written, the controller was able to verify that his behaviour had changed appropriately, with as little fuss as possible. What&#8217;s more, he had those tests available to him going forward, so his behaviour <em>stayed</em> fixed. Eventually he became one of the most important classes in the system, responsible for the interactions of ten other imports &#8211; but he never got overwhelmed by the job.</p>
<p>We can do the same thing with scenarios and applications, or performance tests and whole systems. The ability to define the behaviour we want is one of the most important aspects of changing the behaviour which exists.</p>
]]></content:encoded>
			<wfw:commentRss>http://lizkeogh.com/2010/12/02/giving-effective-feedback-how-to-change-your-codes-behaviour/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What not to test</title>
		<link>http://lizkeogh.com/2010/07/23/what-not-to-test/</link>
		<comments>http://lizkeogh.com/2010/07/23/what-not-to-test/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 21:27:03 +0000</pubDate>
		<dc:creator>liz</dc:creator>
				<category><![CDATA[bdd]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://lizkeogh.com/?p=590</guid>
		<description><![CDATA[A couple of people have recently written asking for advice on how to start writing scenarios. In both instances, they have started by logging in, because &#8220;that&#8217;s what the users do first&#8221;.
If you&#8217;re doing BDD, may I suggest starting not with the scenario that describes the entire user journey, but instead, the scenario that describes [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of people have recently written asking for advice on how to start writing scenarios. In both instances, they have started by logging in, because &#8220;that&#8217;s what the users do first&#8221;.</p>
<p>If you&#8217;re doing BDD, may I suggest starting not with the scenario that describes the entire user journey, but instead, the scenario that describes the <em>riskiest</em> bits of the journey?</p>
<p>Assume that whichever user has access to the system is already logged in. Logging in isn&#8217;t exactly risky. It&#8217;s been done 15,000 times before.</p>
<p>Hard-code the data to start with. Getting data out of a database isn&#8217;t very risky either. You can code this later without affecting the scenarios, if you can get some realistic examples of data.</p>
<p>Work out which bits of the system you know least about. Create the scenarios and have conversations around those bits of the system. You don&#8217;t have to grow the system from the beginning &#8211; you can pick any point you like! Which bits of the system make you most uncomfortable? Which bits make your stakeholders most uncomfortable?</p>
<p>Those are probably the bits which will cause your project to succeed or fail. Logging in can come later, and by the time you come to code it, you&#8217;ll have some real value that people want to log in <em>for</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lizkeogh.com/2010/07/23/what-not-to-test/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Testing vs. BDD</title>
		<link>http://lizkeogh.com/2009/09/05/testing-vs-bdd/</link>
		<comments>http://lizkeogh.com/2009/09/05/testing-vs-bdd/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 10:58:35 +0000</pubDate>
		<dc:creator>liz</dc:creator>
				<category><![CDATA[bdd]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://lizkeogh.com/?p=430</guid>
		<description><![CDATA[I&#8217;ve found a few places recently where the word &#8220;Test&#8221; has been used in combination with the words &#8220;Behaviour Driven&#8221; (with or without the &#8220;u&#8221;). Normally this makes me wince; the whole origin of BDD was intended to separate the act of describing behaviour through examples from the act of testing! Part of my self-appointed [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve found a few places recently where the word &#8220;Test&#8221; has been <a href="http://www.pyccuracy.org/bdt.html">used in combination with the words &#8220;Behaviour Driven&#8221;</a> (with or without the &#8220;u&#8221;). Normally this makes me wince; the whole origin of BDD was intended to separate the act of describing behaviour through examples from the act of testing! Part of my self-appointed role in the BDD community is to be the anchor at the far end of that scale &#8211; you&#8217;ll hear me say &#8220;It&#8217;s not about testing!&#8221; a lot, especially if I&#8217;m answering a question about how to use <a href="http://jbehave.org">JBehave</a> to produce some particularly complex set of tests.</p>
<p><a href="http://testobsessed.com/2009/09/04/adventures-with-auto-generated-tests-and-rspec/">This post by Elizabeth Hendrickson</a> describes her use of a BDD framework for genuine testing. Here, Elizabeth is acting in the role of a <em>tester</em>, and using RSpec imaginatively to support her work. Testing is a very different discipline to the act of describing what a system should do, or what a class should and should not be responsible for, and I think this example illustrates that point nicely.</p>
<p>If you find yourself struggling with BDD&#8217;s language, or wanting to know how to do something with BDD that only makes sense after the code&#8217;s already been written, separating the idea of testing from describing behaviour and responsibility may help you work out what it is you&#8217;re trying to achieve and express that to others. Testing is crucial to good software development; it may be that you&#8217;re doing something else.</p>
]]></content:encoded>
			<wfw:commentRss>http://lizkeogh.com/2009/09/05/testing-vs-bdd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

