<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: From Mocks to Expando</title>
	<atom:link href="http://nutrun.com/weblog/from-mocks-to-expando/feed/" rel="self" type="application/rss+xml" />
	<link>http://nutrun.com/weblog/from-mocks-to-expando/</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Sat, 05 Jul 2008 16:44:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Ben Butler-Cole</title>
		<link>http://nutrun.com/weblog/from-mocks-to-expando/#comment-248</link>
		<dc:creator>Ben Butler-Cole</dc:creator>
		<pubDate>Wed, 13 Dec 2006 22:17:49 +0000</pubDate>
		<guid isPermaLink="false">http://new-site.nutrun.com/?p=68#comment-248</guid>
		<description>Hi George

Expando appears to be a great way of knocking up a stub, but a poor substitute for  a mock. The problem is that there is no point in the test where you clearly say "the ForwardResponder should forward the response using the dispatcher".

The alternative with mocks (JMock here) reads much better to me:

dispatcher.expects(once())
   .method("forward")
   .with(eq(request), eq(response));

Rather than splitting the statement across a local variable definition, an assignment and an assertion, it's all there in a declarative and fairly readable (modulo Java syntax) way.

I agree with you that mocks returning mocks leave a nasty taste in the mouth. Here I would use a stub (by all means a glossy Expando stub if you have such a thing to hand) for the request which returns the dispatcher mock.

And I would leave assertions about the location passed to the request for another test. Indeed I would extend the "one assert per test" guideline to "one mock per test".

Ben</description>
		<content:encoded><![CDATA[<p>Hi George</p>
<p>Expando appears to be a great way of knocking up a stub, but a poor substitute for  a mock. The problem is that there is no point in the test where you clearly say &#8220;the ForwardResponder should forward the response using the dispatcher&#8221;.</p>
<p>The alternative with mocks (JMock here) reads much better to me:</p>
<p>dispatcher.expects(once())<br />
   .method(&#8221;forward&#8221;)<br />
   .with(eq(request), eq(response));</p>
<p>Rather than splitting the statement across a local variable definition, an assignment and an assertion, it&#8217;s all there in a declarative and fairly readable (modulo Java syntax) way.</p>
<p>I agree with you that mocks returning mocks leave a nasty taste in the mouth. Here I would use a stub (by all means a glossy Expando stub if you have such a thing to hand) for the request which returns the dispatcher mock.</p>
<p>And I would leave assertions about the location passed to the request for another test. Indeed I would extend the &#8220;one assert per test&#8221; guideline to &#8220;one mock per test&#8221;.</p>
<p>Ben</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse O'Neill-Oine</title>
		<link>http://nutrun.com/weblog/from-mocks-to-expando/#comment-249</link>
		<dc:creator>Jesse O'Neill-Oine</dc:creator>
		<pubDate>Mon, 11 Dec 2006 06:06:02 +0000</pubDate>
		<guid isPermaLink="false">http://new-site.nutrun.com/?p=68#comment-249</guid>
		<description>This solution just gives you that "yeah, that's how that should work" feeling.  This same pattern would work great in JavaScript too, which is nice in a Web 2.1415 world. Stub on steroids seems like the perfect description.

Thanks!</description>
		<content:encoded><![CDATA[<p>This solution just gives you that &#8220;yeah, that&#8217;s how that should work&#8221; feeling.  This same pattern would work great in JavaScript too, which is nice in a Web 2.1415 world. Stub on steroids seems like the perfect description.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George Malamidis</title>
		<link>http://nutrun.com/weblog/from-mocks-to-expando/#comment-247</link>
		<dc:creator>George Malamidis</dc:creator>
		<pubDate>Fri, 08 Dec 2006 15:09:00 +0000</pubDate>
		<guid isPermaLink="false">http://new-site.nutrun.com/?p=68#comment-247</guid>
		<description>Geert,

Yes, you're right. I've ammended the test to reflect your and Nat's observation. Thanks for pointing this out.</description>
		<content:encoded><![CDATA[<p>Geert,</p>
<p>Yes, you&#8217;re right. I&#8217;ve ammended the test to reflect your and Nat&#8217;s observation. Thanks for pointing this out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geert Baeyaert</title>
		<link>http://nutrun.com/weblog/from-mocks-to-expando/#comment-246</link>
		<dc:creator>Geert Baeyaert</dc:creator>
		<pubDate>Fri, 08 Dec 2006 13:56:05 +0000</pubDate>
		<guid isPermaLink="false">http://new-site.nutrun.com/?p=68#comment-246</guid>
		<description>This is puzzling.

As far as I understand, if getRequestDispatcher is not called, the code in the closure won't be executed, including any asserts that might be there.

What am I not seeing?</description>
		<content:encoded><![CDATA[<p>This is puzzling.</p>
<p>As far as I understand, if getRequestDispatcher is not called, the code in the closure won&#8217;t be executed, including any asserts that might be there.</p>
<p>What am I not seeing?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Santini</title>
		<link>http://nutrun.com/weblog/from-mocks-to-expando/#comment-245</link>
		<dc:creator>Jeff Santini</dc:creator>
		<pubDate>Fri, 08 Dec 2006 10:40:35 +0000</pubDate>
		<guid isPermaLink="false">http://new-site.nutrun.com/?p=68#comment-245</guid>
		<description>Actually the paper is not that short, sections 4 "Mock Objects in Practice" and 5 "Misconceptions about Mocks" are the bits more related to how Mocks can go wrong and what is the pro-Mock answer to these problems.</description>
		<content:encoded><![CDATA[<p>Actually the paper is not that short, sections 4 &#8220;Mock Objects in Practice&#8221; and 5 &#8220;Misconceptions about Mocks&#8221; are the bits more related to how Mocks can go wrong and what is the pro-Mock answer to these problems.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Santini</title>
		<link>http://nutrun.com/weblog/from-mocks-to-expando/#comment-244</link>
		<dc:creator>Jeff Santini</dc:creator>
		<pubDate>Fri, 08 Dec 2006 10:35:53 +0000</pubDate>
		<guid isPermaLink="false">http://new-site.nutrun.com/?p=68#comment-244</guid>
		<description>Hi George,

I am very much in favor of your "crusade" against the bad things people can do with mock libraries.  In relation to Nat's comment above and your reply that your expando object is a mock, would I be right in saying people who compain about mocks(myself included) do so pretty much because of their misuse, not because they serve no purpose?

The paper at http://www.jmock.org/oopsla2004.pdf lays out the case for mocks.  Is there anything in there to disagree with?</description>
		<content:encoded><![CDATA[<p>Hi George,</p>
<p>I am very much in favor of your &#8220;crusade&#8221; against the bad things people can do with mock libraries.  In relation to Nat&#8217;s comment above and your reply that your expando object is a mock, would I be right in saying people who compain about mocks(myself included) do so pretty much because of their misuse, not because they serve no purpose?</p>
<p>The paper at <a href="http://www.jmock.org/oopsla2004.pdf" rel="nofollow">http://www.jmock.org/oopsla2004.pdf</a> lays out the case for mocks.  Is there anything in there to disagree with?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://nutrun.com/weblog/from-mocks-to-expando/#comment-243</link>
		<dc:creator>James</dc:creator>
		<pubDate>Fri, 08 Dec 2006 09:28:25 +0000</pubDate>
		<guid isPermaLink="false">http://new-site.nutrun.com/?p=68#comment-243</guid>
		<description>Seems like my post has been truncated.

Here's a link to the example Ruby test using Mocha.

http://pastie.caboo.se/26540</description>
		<content:encoded><![CDATA[<p>Seems like my post has been truncated.</p>
<p>Here&#8217;s a link to the example Ruby test using Mocha.</p>
<p><a href="http://pastie.caboo.se/26540" rel="nofollow">http://pastie.caboo.se/26540</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George Malamidis</title>
		<link>http://nutrun.com/weblog/from-mocks-to-expando/#comment-242</link>
		<dc:creator>George Malamidis</dc:creator>
		<pubDate>Fri, 08 Dec 2006 09:21:01 +0000</pubDate>
		<guid isPermaLink="false">http://new-site.nutrun.com/?p=68#comment-242</guid>
		<description>&lt;strike&gt;Geert,&lt;/strike&gt;

&lt;strike&gt;assert "/location" == location&lt;/strike&gt;

&lt;strike&gt;If getRequestDispatcher() is not called, this assertion will fail.&lt;/strike&gt;

&lt;strike&gt;Same goes for the assertions relevant to the forward() method &lt;/strike&gt;</description>
		<content:encoded><![CDATA[<p><strike>Geert,</strike></p>
<p><strike>assert &#8220;/location&#8221; == location</strike></p>
<p><strike>If getRequestDispatcher() is not called, this assertion will fail.</strike></p>
<p><strike>Same goes for the assertions relevant to the forward() method </strike></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://nutrun.com/weblog/from-mocks-to-expando/#comment-241</link>
		<dc:creator>James</dc:creator>
		<pubDate>Fri, 08 Dec 2006 09:19:01 +0000</pubDate>
		<guid isPermaLink="false">http://new-site.nutrun.com/?p=68#comment-241</guid>
		<description>I think your comparison is a little unfair. It would be better if you wrote out the code for the version of the test using mocks. I've had a quick attempt at writing an equivalent test in Ruby using the Mocha mocking library and I would say it compares very favourably with your Expando based one...

require 'mocha'
require 'test/unit'

class ForwardResponderTest</description>
		<content:encoded><![CDATA[<p>I think your comparison is a little unfair. It would be better if you wrote out the code for the version of the test using mocks. I&#8217;ve had a quick attempt at writing an equivalent test in Ruby using the Mocha mocking library and I would say it compares very favourably with your Expando based one&#8230;</p>
<p>require &#8216;mocha&#8217;<br />
require &#8216;test/unit&#8217;</p>
<p>class ForwardResponderTest</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geert Baeyaert</title>
		<link>http://nutrun.com/weblog/from-mocks-to-expando/#comment-240</link>
		<dc:creator>Geert Baeyaert</dc:creator>
		<pubDate>Fri, 08 Dec 2006 08:55:43 +0000</pubDate>
		<guid isPermaLink="false">http://new-site.nutrun.com/?p=68#comment-240</guid>
		<description>Yes, but as Nat said, it doesn't tell you whether any of the expected calls was actually called.

Doesn't that worry you?</description>
		<content:encoded><![CDATA[<p>Yes, but as Nat said, it doesn&#8217;t tell you whether any of the expected calls was actually called.</p>
<p>Doesn&#8217;t that worry you?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
