<?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>ryan norris &#187; rhinomocks</title>
	<atom:link href="http://www.ryannorris.com/tag/rhinomocks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ryannorris.com</link>
	<description>managing software teams and delivering great results</description>
	<lastBuildDate>Fri, 25 Jun 2010 13:44:27 +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>Mocks &#8211; the only thing separating complex TDD from value-added TDD</title>
		<link>http://www.ryannorris.com/2009/04/08/mocks-the-only-thing-separating-complex-tdd-from-value-added-tdd/</link>
		<comments>http://www.ryannorris.com/2009/04/08/mocks-the-only-thing-separating-complex-tdd-from-value-added-tdd/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 03:18:05 +0000</pubDate>
		<dc:creator>Ryan Norris</dc:creator>
				<category><![CDATA[Building Better Software]]></category>
		<category><![CDATA[Enterprise Architecture]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[integration testing]]></category>
		<category><![CDATA[mockito]]></category>
		<category><![CDATA[rhinomocks]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://www.ryannorris.com/?p=64</guid>
		<description><![CDATA[About two years back when I started getting completely fascist about test-driven development, the complexity was always &#8220;gee, i have an application container and I need to involve it in my unit tests so that I can get full test coverage !!111oneeleventy.&#8221; This typically meant providing a real collaborator, like a PersistenceUnit in Java, so [...]]]></description>
			<content:encoded><![CDATA[<p>About two years back when I started getting completely fascist about test-driven development, the complexity was always &#8220;gee, i have an application container and I need to involve it in my unit tests so that I can get full test coverage !!111oneeleventy.&#8221;</p>
<p>This typically meant providing a real <em>collaborator</em>, like a PersistenceUnit in Java, so that I could test trivial operations like persisting an entity.  At the time, I challenged a manager on this:</p>
<p><em>What are we really testing?  Are we testing OUR requirement, or are we testing something we should reasonably expect Hibernate to do on the basis of our initial technology selection?</em></p>
<p>Code coverage I believe is pretty overrated.  No one cares whether or not you can prove your method to persist an entity works <strong>because the developers of Hibernate/TopLink/LINQ to SQL have already proved this through their unit tests. </strong>What you are building when you write a test that actually checks the database to see if <em>your middleware </em>used a pre-packaged <em>object-relational manpping framework</em> correctly is an integration test.  There&#8217;s certainly value to integration testing with data access layers, particularly when difficult to test components of your middleware (like stored procedures and triggers) are involved.  Saving that however, the focus of test-driven development &#8211; namely unit tests, should be on the business logic that is proprietary to your applicatiom, be it the front-end or the middle tier.</p>
<p>Now, suffice to say that to a good number of developers and architects this isn&#8217;t news, but if you really want to <em>isolate</em> the code which you wrote that is specific to your business rules and requirements &#8211; <strong>mocking frameworks</strong> are the way to go.  Particularly in an Agile project where we can readily identify certain injected dependencies (like an EntityManager, for example) as a <em>collaborator </em>of the class under test, your unit test is really interested in asking the question <em>based on this interaction with this external component, how should I expect my logic to react?</em></p>
<p>In these scenarios of course, I mock or stub the <em>EntityManager</em>.  In the past, a fool like me would have tried to load a container within my unit test environment.  This is actually an integration test, in addition to the fact that it is costly and doesn&#8217;t add the value a truly isolated unit test which focuses on the code <em>you wrote</em> does.</p>
<p>In .Net, <a title="RhinoMocks" href="http://ayende.com/projects/rhino-mocks.aspx" target="_blank">RhinoMocks</a> is scalding hot with it&#8217;s supprt for mocking through lambda&#8217;s.  In JEE, I&#8217;ve fallen in love with <a title="Mockito" href="http://mockito.org/" target="_self">Mockito</a>.</p>
<p>So, stop worrying about how you can get JBoss running so that your CI environment can execute inside of it.  Instead, use mocks to give your code the resources it needs to vet out the conditions in your own code that you want to test.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryannorris.com/2009/04/08/mocks-the-only-thing-separating-complex-tdd-from-value-added-tdd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
