<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Durable Methods of Jamie McIlroy &#187; Mock Objects</title>
	<atom:link href="http://jamiemcilroy.wordpress.com/category/development/mock-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamiemcilroy.wordpress.com</link>
	<description>A collection of thoughts and solutions from an independent software Integration Consultant</description>
	<lastBuildDate>Mon, 06 Nov 2006 21:10:34 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='jamiemcilroy.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/b47c118a85f142ebf7dbb7e24b4829e4?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>The Durable Methods of Jamie McIlroy &#187; Mock Objects</title>
		<link>http://jamiemcilroy.wordpress.com</link>
	</image>
			<item>
		<title>Mocking a Web Service</title>
		<link>http://jamiemcilroy.wordpress.com/2005/10/07/mocking-a-web-service/</link>
		<comments>http://jamiemcilroy.wordpress.com/2005/10/07/mocking-a-web-service/#comments</comments>
		<pubDate>Fri, 07 Oct 2005 16:09:34 +0000</pubDate>
		<dc:creator>Jamie McIlroy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Mock Objects]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">https://jamiemcilroy.wordpress.com/2005/10/07/mocking-a-web-service/</guid>
		<description><![CDATA[I like the idea of Mock Objects, I like what they stand for and the development speed they enable. I typically write my own and that makes me feel a little like someone at the edge of the room. When I get the time to investigate the Mock frameworks available, I&#8217;m sure I&#8217;ll think of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jamiemcilroy.wordpress.com&blog=352686&post=7&subd=jamiemcilroy&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I like the idea of <a href="http://www.mockobjects.com/FrontPage.html" target="_blank">Mock Objects</a>, I like what they stand for and the development speed they enable. I typically write my own and that makes me feel a little like someone at the edge of the room. When I get the time to investigate the Mock frameworks available, I&#8217;m sure I&#8217;ll think of this post and wonder why I was making life more difficult.</p>
<p>The issue is mocking an object you&#8217;re expecting from a web service. You don&#8217;t have control of the object so you can&#8217;t expect it to implement a desired interface (as I would normally do). You find yourself writing tests with real, hot wired objects &#8212; this is wrong for more ways than I care to get into on a Friday morning.</p>
<p>My first thought was <a href="http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse.jdt.doc.user/tasks/tasks-218.htm" target="_blank">extracting an interface</a> from the type generated by the Web Service. I can then create a Mocked Type in my test package and implement that interface. I gave myself a little pat on the back and went about my business with writing some tests. I wrote tests for a day in my happy, ignorant little mock world, disconnected from the Service and speeding through my requirements.</p>
<p>I&#8217;m lucky enough to sit around the corner from the fellow writing these Services. He stopped by my desk to ask whether his changes to the Service object had caused any problems in my project. Pride gathering beneath the surface; I was about to outline my mocking technique. An anxiety filled &#8220;did I leave the iron on?&#8221; type of thought came roaring into mind.</p>
<p>&#8220;I&#8217;m not sure Jeff, let me get back to you on that one&#8221;.</p>
<p>Of course it had an impact.</p>
<p>My interface was based on what the type looked like from the day I extracted it. The type changed but without holding a true relationship (I couldn&#8217;t have the Wizard change the Service object to implement the new interface, it would break the moment I regenerated the client) with my interface. I was testing an irrelevant piece of software&#8230; The Titanic was sinking and I was checking the sound system in the Grand Ballroom&#8230;</p>
<p>So here&#8217;s what I did.</p>
<p>I deleted the interface and had my mock extend the Service object itself. When the client is regenerated, any changes to the Service object&#8217;s structure will cause my mock to break; I get notified right away (when I try running the tests).</p>
<p>It&#8217;s not the cleanest solution to this particular problem but it gets around that isolated feeling of ignorance I was starting to sense. It allows me to write software against something that looks and feels like the service object without being connected to the Service itself.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/jamiemcilroy.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/jamiemcilroy.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jamiemcilroy.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jamiemcilroy.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jamiemcilroy.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jamiemcilroy.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jamiemcilroy.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jamiemcilroy.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jamiemcilroy.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jamiemcilroy.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jamiemcilroy.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jamiemcilroy.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jamiemcilroy.wordpress.com&blog=352686&post=7&subd=jamiemcilroy&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://jamiemcilroy.wordpress.com/2005/10/07/mocking-a-web-service/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2ae0856f19101a17117bd564b873ce34?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jamiemcilroy</media:title>
		</media:content>
	</item>
	</channel>
</rss>