<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-7624394686148711990.post90437225413153389..comments</id><updated>2009-09-02T10:12:18.036+10:00</updated><title type='text'>Comments on dave^2 = -1: An example of driving design through top-down test...</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.davesquared.net/feeds/90437225413153389/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7624394686148711990/90437225413153389/comments/default'/><link rel='alternate' type='text/html' href='http://www.davesquared.net/2009/09/example-of-driving-design-through-top.html'/><author><name>David</name><uri>http://www.blogger.com/profile/05155410712205848106</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7624394686148711990.post-3834116254515625890</id><published>2009-09-02T10:12:18.036+10:00</published><updated>2009-09-02T10:12:18.036+10:00</updated><title type='text'>Hi Mike,

Hope this managed to go part way towards...</title><content type='html'>Hi Mike,&lt;br /&gt;&lt;br /&gt;Hope this managed to go part way towards answer some of the questions you raised last post.&lt;br /&gt;&lt;br /&gt;My take on mocking frameworks is to not use them until it is blindingly obvious you need one (this implies you&amp;#39;ve looked at them and have an idea of what they do). This means hand-writing all your mocks/stubs for tests until you get so sick of it you are forced to use a framework. :)&lt;br /&gt;&lt;br /&gt;Going through this process will automatically answer the when/when not to use them question. I found it invaluable.&lt;br /&gt;&lt;br /&gt;And your description of how stubbing a method call works is perfect. :)&lt;br /&gt;&lt;br /&gt;Why didn&amp;#39;t I mock report data? Completely arbitrary decision. You definitely could mock it, and it might be a better decision to do so because then you can change how that class works without breaking tests. &lt;br /&gt;&lt;br /&gt;For this case the Results class is a dumb Data Transfer Object (DTO). It has no behaviour of its own, it is simply holding data. By not mocking it I&amp;#39;ve pretty much committed to keeping it as such. Mocking would give me more ability to change this.&lt;br /&gt;&lt;br /&gt;In retrospect this was an unfortunate decision for an explanatory blog post as it unnecessarily confuses things. Sorry. :-\&lt;br /&gt;&lt;br /&gt;You are also right about the purpose of mocking being isolation of the sut from its dependencies. It&amp;#39;s definitely not the intention to go and replace the mocks/stubs used in tests with real versions.&lt;br /&gt;&lt;br /&gt;In terms of the &amp;quot;Aha!&amp;quot; moment for mocking, I think the first step is to work on basic dependency injection first (not DI containers, just plain old constructor injection), and manually code the fake versions of these for tests. The progression to a mocking framework will start to happen naturally from there.&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;David</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7624394686148711990/90437225413153389/comments/default/3834116254515625890'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7624394686148711990/90437225413153389/comments/default/3834116254515625890'/><link rel='alternate' type='text/html' href='http://www.davesquared.net/2009/09/example-of-driving-design-through-top.html?showComment=1251850338036#c3834116254515625890' title=''/><author><name>David</name><uri>http://www.blogger.com/profile/05155410712205848106</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='15069573216606975109'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.davesquared.net/2009/09/example-of-driving-design-through-top.html' ref='tag:blogger.com,1999:blog-7624394686148711990.post-90437225413153389' source='http://www.blogger.com/feeds/7624394686148711990/posts/default/90437225413153389' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-7624394686148711990.post-4496452052623766917</id><published>2009-09-02T06:06:12.812+10:00</published><updated>2009-09-02T06:06:12.812+10:00</updated><title type='text'>Great post!  Thanks, it was very helpful to go thr...</title><content type='html'>Great post!  Thanks, it was very helpful to go through that same mental process that you guys went through.  I realize this wasn&amp;#39;t a representation of everything there is to know about testing and design, but it seems that if you follow these guidelines, you&amp;#39;re in for some simple, organized, and maintainable code that you can feel confident about.&lt;br /&gt;&lt;br /&gt;I do want to ask a follow up question or two, however.  I understand the need for mocking frameworks, but I&amp;#39;ve never used them yet.  It would be helpful if you could briefly describe your take on the role and need such frameworks fill when testing and when to use them and when not to.  Also, just to make sure I understand, when a mocking framework stubs a method call, it creates some fake, relatively empty implementation of that method and it&amp;#39;s return value (which you can also configure to be whatever you want), correct?&lt;br /&gt;&lt;br /&gt;As for this example, we used a mock for an unimplemented IIntegerArrayDataSerialiser.  I think that makes sense, in that we can continue with our current SUT and not get unnecessarily sidelined at the current moment with one of it&amp;#39;s dependencies.  But why didn&amp;#39;t we mock getting the report data as well?  This is the part I am the most confused about.  I&amp;#39;m sure we won&amp;#39;t go back through our tests and remove mocking stubs once implementations are created for dependencies, so that can&amp;#39;t be the one big compelling reason for mocking.  The whole point is to test things in isolation from their dependencies, correct?&lt;br /&gt;&lt;br /&gt;I don&amp;#39;t think I&amp;#39;m mixed up, but I just haven&amp;#39;t had the &amp;quot;Aha!&amp;quot; moment regarding mocking yet.  Thanks in advance for any guidance or explanation you can provide.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7624394686148711990/90437225413153389/comments/default/4496452052623766917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7624394686148711990/90437225413153389/comments/default/4496452052623766917'/><link rel='alternate' type='text/html' href='http://www.davesquared.net/2009/09/example-of-driving-design-through-top.html?showComment=1251835572812#c4496452052623766917' title=''/><author><name>Mike Murray</name><uri>http://www.blogger.com/profile/01990150469958605173</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.davesquared.net/2009/09/example-of-driving-design-through-top.html' ref='tag:blogger.com,1999:blog-7624394686148711990.post-90437225413153389' source='http://www.blogger.com/feeds/7624394686148711990/posts/default/90437225413153389' type='text/html'/></entry></feed>