<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The mess that mocks can make</title><link>http://blogs.msdn.com/agilemonkey/archive/2007/07/13/the-mess-that-mocks-can-make.aspx</link><description>Aside: I guess this post is really about mock frameworks rather than mocks, but I didn't want to break the partial alliteration I had going in the title :) A question was posed recently on one of our discussion lists about whether Rhino Mocks was a good</description><dc:language>en-CA</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: The mess that mocks can make</title><link>http://blogs.msdn.com/agilemonkey/archive/2007/07/13/the-mess-that-mocks-can-make.aspx#3846059</link><pubDate>Fri, 13 Jul 2007 15:09:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3846059</guid><dc:creator>Micah</dc:creator><description>&lt;p&gt;I'm actually new to agile development, and I was using Rhino Mock to test a controller by mocking a passive view when I realized I was not gaining anything. It took about five minutes to write a mock that wouldn't break when the controller was refactored.&lt;/p&gt;
&lt;p&gt;It seems that mock frameworks are something that I will know when I need, but until then they should be avoided.&lt;/p&gt;</description></item><item><title>re: The mess that mocks can make</title><link>http://blogs.msdn.com/agilemonkey/archive/2007/07/13/the-mess-that-mocks-can-make.aspx#3847128</link><pubDate>Fri, 13 Jul 2007 16:18:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3847128</guid><dc:creator>casper</dc:creator><description>&lt;p&gt;Yes, it's too bad these frameworks don't come with a warning sticker on them :) I wouldn't say it's necessarily something you'll _ever_ need either. You _may_, and it's good to know they exist, but so far I've been quite happy without them.&lt;/p&gt;
</description></item><item><title>re: The mess that mocks can make</title><link>http://blogs.msdn.com/agilemonkey/archive/2007/07/13/the-mess-that-mocks-can-make.aspx#4353090</link><pubDate>Sun, 12 Aug 2007 21:09:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4353090</guid><dc:creator>Nikola Malovic</dc:creator><description>&lt;p&gt;Well, I disagree with you in couple of things :)&lt;/p&gt;
&lt;p&gt;Regarding a) “the behavior”&lt;/p&gt;
&lt;p&gt;By my understanding, the purpose of mocking is to test the behaviors VS unit tests which test the execution contexts. If I would right the test with some mock about some method, I am testing and contracting the behavior of that method. If that would change, I would like to have a broken test pointing me to that. In case I wouldn’t want to be constrained with contracted behaviors, I wouldn’t use mocking framework at all&lt;/p&gt;
&lt;p&gt;Regarding b) “the sequence”&lt;/p&gt;
&lt;p&gt;Rhino mocks recording mode is by default set to unordered, so in this example even if you change the sequence unit test would still work. If you manually set the mockery to record expectations in ordered mode, where sequence is important, I think that represent the test intention which I would like, in case sequence had changed, to result in broken test&lt;/p&gt;
&lt;p&gt;Regarding stub vs mock&lt;/p&gt;
&lt;p&gt;TDD (EDD) as “test first” development environment requires abstracted “fake” representations of the concepts tested even before the real one would be created. First downside of using stubs is that at the end of big project there’s a big pile of type stubs totally unused which complete removal is usually very tricky and time consuming task. Second downside is that stubs are not automatically updated when the type they stub would change. Therefore the test would still be green with the stub, but the stub would be wrong&lt;/p&gt;</description></item><item><title>re: The mess that mocks can make</title><link>http://blogs.msdn.com/agilemonkey/archive/2007/07/13/the-mess-that-mocks-can-make.aspx#4455624</link><pubDate>Sun, 19 Aug 2007 03:04:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4455624</guid><dc:creator>Brian Button</dc:creator><description>&lt;p&gt;Ah, Casper, &lt;/p&gt;
&lt;p&gt;You have channeled my question about Mocks and Mock Object Frameworks 100%. I have the exact same questions as you, the exact same reactions as you, and I'm just as confused as you.&lt;/p&gt;
&lt;p&gt;I tracked down a few different people at the conference to have them explain it to me and it makes a bit more sense. If you look at the blog entry I pointed you to at the conference (A Deep Dive into Test Driven Development, Oct, 2004), I'm planning on redoing that example using Rhino Mocks and blogging where it takes me. &lt;/p&gt;
&lt;p&gt;There is enough refactoring in there to test out this way of writing tests. Who knows, maybe I'll learn something new!&lt;/p&gt;
&lt;p&gt;-- bab&lt;/p&gt;</description></item><item><title>re: The mess that mocks can make</title><link>http://blogs.msdn.com/agilemonkey/archive/2007/07/13/the-mess-that-mocks-can-make.aspx#4463628</link><pubDate>Sun, 19 Aug 2007 16:18:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4463628</guid><dc:creator>casper</dc:creator><description>&lt;p&gt;Looking forward to reading about your discoveries Brian :) I did read through your Deep Dive series, as well as the 2005 refactoring of the Video Store example.&lt;/p&gt;
&lt;p&gt;I hate to be an echo chamber, but I did learn a few things from those posts and so I'll be linking to them soon :)&lt;/p&gt;
</description></item><item><title>re: The mess that mocks can make</title><link>http://blogs.msdn.com/agilemonkey/archive/2007/07/13/the-mess-that-mocks-can-make.aspx#4474186</link><pubDate>Mon, 20 Aug 2007 09:01:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4474186</guid><dc:creator>casper</dc:creator><description>&lt;p&gt;Nikola: Sorry for taking so long to reply. &lt;/p&gt;
&lt;p&gt;a) I'm not claiming that mocks don't test the contract or behaviour of a method. My point is that you often write several tests for a single method, and if you are using a mock framework, it's not easy to refactor that method if/when it changes. Your tests will still fail if you create a real class for the mock.&lt;/p&gt;
&lt;p&gt;b) I don't think I've claimed that order of the tests is important anywhere .. maybe you could explain this point a bit more?&lt;/p&gt;
&lt;p&gt;c) I'll have to disagree that having a 'big pile of type stubs' at the end of a project is a bad thing. They should be located in your test assembly and not have any effect on the rest of the system. I'm also not sure why you would want to completely remove them.&lt;/p&gt;</description></item><item><title>re: The mess that mocks can make</title><link>http://blogs.msdn.com/agilemonkey/archive/2007/07/13/the-mess-that-mocks-can-make.aspx#6014094</link><pubDate>Fri, 09 Nov 2007 14:27:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6014094</guid><dc:creator>malovicn</dc:creator><description>&lt;p&gt;I was commenting your next sentences:&lt;/p&gt;
&lt;p&gt;========&lt;/p&gt;
&lt;p&gt;If you look carefully at how the mock object is created, you're really just setting up (a) expected behaviours and possibly (b) an expected sequence of calls. &amp;nbsp;When code is refactored, unless you're accessing a public API, chances are that you will need to change both (a) and (b). That means going back through each unit test and making the changes by hand. Not very agile&lt;/p&gt;
&lt;p&gt;===============&lt;/p&gt;
&lt;p&gt;re: a)&lt;/p&gt;
&lt;p&gt;The difference you are describing exists only in NMock where method names are strings. My point was that with the Rhino Mocks we have strongly typed mock members accessors so there is no difference at all (in that sense) in refactoring benefits of using stubs vs mocks &amp;nbsp; &lt;/p&gt;
&lt;p&gt;re: b) &lt;/p&gt;
&lt;p&gt;I just said that if you don't explicitly contract the &amp;quot;expected sequence of calls&amp;quot; (that stands for ordered set of action, right?) Rhino mocks won't break a test.By default, Rhino mock don't care about the order of expectations.&lt;/p&gt;
&lt;p&gt;re: c) &lt;/p&gt;
&lt;p&gt;I don't see any advantage in using stubs in tests (two points above are some of examples), so beeing forced to create a bunch of &amp;quot;paralel&amp;quot; types somewhere just to run tests sounds as an extra work to me. Another thing, in case of stubs when &amp;quot;original&amp;quot; type is been updated, the &amp;quot;stubbed&amp;quot; one has to be updated manualy too. In case of mocks (due to their dynamic nature) no extra &amp;quot;parallel&amp;quot; work needed&lt;/p&gt;</description></item><item><title>re: The mess that mocks can make</title><link>http://blogs.msdn.com/agilemonkey/archive/2007/07/13/the-mess-that-mocks-can-make.aspx#6014159</link><pubDate>Fri, 09 Nov 2007 14:29:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6014159</guid><dc:creator>malovicn</dc:creator><description>&lt;p&gt;Just a side note (delete it if you like): I don't know why I've now different nick on the site but malovicn and Nikola Malovic are both me :)&lt;/p&gt;</description></item></channel></rss>