<?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>mattdavid.net &#187; Testing</title>
	<atom:link href="http://mattdavid.net/category/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattdavid.net</link>
	<description></description>
	<lastBuildDate>Wed, 24 Feb 2010 06:42:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>TDD Is About Design, Not Testing</title>
		<link>http://mattdavid.net/2009/01/20/tdd-is-about-design-not-testing/</link>
		<comments>http://mattdavid.net/2009/01/20/tdd-is-about-design-not-testing/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 04:19:06 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://mattdavid.net/2009/01/20/tdd-is-about-design-not-testing/</guid>
		<description><![CDATA[I was recently reminded of this by Scott Bellware on this hanselminutes episode. It&#8217;s easy to fall into the trap of thinking about TDD as a testing technique.  I mean, Test is the first word in TDD.  And normally you hear it talked about as Test Driven Development, not Test Driven Design.  Since most development [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fmattdavid.net%2F2009%2F01%2F20%2Ftdd-is-about-design-not-testing%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fmattdavid.net%2F2009%2F01%2F20%2Ftdd-is-about-design-not-testing%2F&amp;style=compact&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>I was recently reminded of this by <a href="http://blog.scottbellware.com/">Scott Bellware</a> on <a href="http://www.hanselman.com/blog/HanselminutesPodcast146TestDrivenDevelopmentIsDesignTheLastWordOnTDD.aspx">this hanselminutes episode</a>.</p>
<p>It&#8217;s easy to fall into the trap of thinking about TDD as a testing technique.  I mean, Test <em>is</em> the first word in TDD.  And normally you hear it talked about as <strong>T</strong>est <strong>D</strong>riven <strong>D</strong>evelopment, not <strong>T</strong>est <strong>D</strong>riven <strong>D</strong>esign.  Since most development going on is probably not <a href="http://en.wikipedia.org/wiki/Greenfield_project">Greenfield</a>, but is in maintenance/support mode, I&#8217;d bet that those involved with most applications think that the design phase is &#8220;done&#8221;.  Even when new features are being added to an existing application/platform, it&#8217;s not like you&#8217;re starting from scratch, you&#8217;re usually bolting things on to existing functionality.</p>
<p>And therein lies a pitfall.  Most people would probably be more concerned with not breaking existing functionality, as opposed to letting TDD help design the new functionality.</p>
<p>Another pitfall comes from that first word, Test.  Don&#8217;t get me wrong, I love tests.  However, it is quite possible that you follow the <a href="http://en.wikipedia.org/wiki/Test-driven_development#Test-Driven_Development_Cycle">red/green/refactor</a> methodology of writing tests and still come out with poorly designed code. This comes from what I like to call the &#8220;Mother of Invention Principle&#8221;.  Yeah, I just coined a principle.  Basically, one of the ideas of TDD is that there should be no new code added until it is required by at least one test.  So, if you follow this principle, then you should technically have 100% code coverage when finished.</p>
<p>Unfortunately, 100% code coverage isn&#8217;t useful.  Anything but 100% would be useful (but more on that in another post.)  Maybe the tests were poorly designed.  Maybe the tests are spot on, but they require huge amounts of setup and teardown for each test.  Sure, it&#8217;s tested, but is it designed well?</p>
<p>This kind of thinking, about &#8220;fully&#8221; tested code, sure make TDD a good sell to management and QA, but alas, that&#8217;s not what TDD was meant for.</p>
<p>Anyway, I won&#8217;t belabor the point, listen to the podcast.  Scott and Scott talk about this much more eloquently than I can.</p>
]]></content:encoded>
			<wfw:commentRss>http://mattdavid.net/2009/01/20/tdd-is-about-design-not-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spectacle</title>
		<link>http://mattdavid.net/2008/12/14/spectacle/</link>
		<comments>http://mattdavid.net/2008/12/14/spectacle/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 16:40:43 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Spectacle]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://mattdavid.net/2008/12/14/spectacle/</guid>
		<description><![CDATA[I&#8217;ve don&#8217;t like writing unit tests, plain and simple.  Do I write test code?  Absolutely.  I think not writing tests will set you up for a truckload of fail. What I don&#8217;t like about writing the tests is the seemingly foreign language that their written in.  Sure it might be C# or VB, but it [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fmattdavid.net%2F2008%2F12%2F14%2Fspectacle%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fmattdavid.net%2F2008%2F12%2F14%2Fspectacle%2F&amp;style=compact&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve don&#8217;t like writing unit tests, plain and simple.  Do I write test code?  Absolutely.  I think not writing tests will set you up for a truckload of fail.</p>
<p>What I don&#8217;t like about writing the tests is the seemingly foreign language that their written in.  Sure it might be C# or VB, but it looks drastically different from the object oriented code we write on a daily basis.</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060;">   1:</span> MyClass superGuy = <span style="color: #0000ff;">new</span> MyClass();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   2:</span> <span style="color: #0000ff;">string</span> result = superGuy.GetResult();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060;">   3:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   4:</span> Assert.AreEqual(<span style="color: #006080;">"good result"</span>, result);</pre>
</div>
</div>
<p>I just don&#8217;t think that way.  For one, I can&#8217;t just look at that line and know what&#8217;s being tested without having to read through the entire line, Two, it takes me a few seconds to mentally adjust to thinking about the code that way.  Finally, I have a tendency to swap the expected and actual when writing out the asserts which confuses me when the assertion fails.</p>
<p>Wouldn&#8217;t it be nice to be able to write:</p>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060;">   1:</span> MyClass superGuy = <span style="color: #0000ff;">new</span> MyClass();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   2:</span> <span style="color: #0000ff;">string</span> result = superGuy.GetResult();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060;">   3:</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   4:</span> result.IsNotNull();</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060;">   5:</span> result.IsEqualTo(<span style="color: #006080;">"good result"</span>);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   6:</span> <span style="color: #008000;">// or combine them</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060;">   7:</span> result.IsNotNull().And.IsEqualTo(<span style="color: #006080;">"good result"</span>);</pre>
</div>
</div>
<p>That&#8217;s what <a href="http://www.github.com/mattdavid/spectacle/tree/master">spectacle</a> is all about.  It&#8217;s a collection of extension methods to ease the pain when writing unit tests.  It only targets MbUnit v2 right now, because that&#8217;s what I&#8217;m currently using.</p>
<p>If you want to try it out, clone it from the github repository and build it.  Next all you&#8217;ll need to do is add a reference to your test project  and add a &#8220;using Spectacle.MbUnitAssertions;&#8221; to your code files.</p>
]]></content:encoded>
			<wfw:commentRss>http://mattdavid.net/2008/12/14/spectacle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
