<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: is there a difference between asking and telling?</title>
	<atom:link href="http://monkeyisland.pl/2008/04/26/asking-and-telling/feed/" rel="self" type="application/rss+xml" />
	<link>http://monkeyisland.pl/2008/04/26/asking-and-telling/</link>
	<description>about software</description>
	<lastBuildDate>Sat, 07 Jan 2012 22:51:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Thrawn</title>
		<link>http://monkeyisland.pl/2008/04/26/asking-and-telling/#comment-3862</link>
		<dc:creator><![CDATA[Thrawn]]></dc:creator>
		<pubDate>Tue, 01 Nov 2011 01:20:15 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=78#comment-3862</guid>
		<description><![CDATA[In the suggested example case of verifying that Logger.log is called - why would you stub it? To stub it means to set up fake data to be returned, but the &#039;log&#039; methods all return void.

If you use Mockito to make a fake Logger and verify that &#039;log&#039; was called, then you&#039;ve made a mock, not a stub.]]></description>
		<content:encoded><![CDATA[<p>In the suggested example case of verifying that Logger.log is called &#8211; why would you stub it? To stub it means to set up fake data to be returned, but the &#8216;log&#8217; methods all return void.</p>
<p>If you use Mockito to make a fake Logger and verify that &#8216;log&#8217; was called, then you&#8217;ve made a mock, not a stub.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hasCode.com &#187; Blog Archive &#187; Mocking, Stubbing and Test Spying using the Mockito Framework</title>
		<link>http://monkeyisland.pl/2008/04/26/asking-and-telling/#comment-3770</link>
		<dc:creator><![CDATA[hasCode.com &#187; Blog Archive &#187; Mocking, Stubbing and Test Spying using the Mockito Framework]]></dc:creator>
		<pubDate>Sun, 27 Mar 2011 11:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=78#comment-3770</guid>
		<description><![CDATA[[...] Verification enables you to test the behaviour of methods with void return but you shouldn&#8217;t overuse this feature .. use JUnit&#8217;s Assert methods when possible, verify when needed.. more about this topic from the creator of Mockito: Szepan Faber: Is there a difference between asking and telling? [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Verification enables you to test the behaviour of methods with void return but you shouldn&#8217;t overuse this feature .. use JUnit&#8217;s Assert methods when possible, verify when needed.. more about this topic from the creator of Mockito: Szepan Faber: Is there a difference between asking and telling? [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spies vs. Mocks &#124; Loosely Connected</title>
		<link>http://monkeyisland.pl/2008/04/26/asking-and-telling/#comment-3762</link>
		<dc:creator><![CDATA[Spies vs. Mocks &#124; Loosely Connected]]></dc:creator>
		<pubDate>Sat, 12 Mar 2011 00:48:45 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=78#comment-3762</guid>
		<description><![CDATA[[...] http://monkeyisland.pl/2008/04/26/asking-and-telling [...]]]></description>
		<content:encoded><![CDATA[<p>[...] <a href="http://monkeyisland.pl/2008/04/26/asking-and-telling" rel="nofollow">http://monkeyisland.pl/2008/04/26/asking-and-telling</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: EasyMock and Mockito, a little comparison &#171; Stefan Hendriks&#039; Blog</title>
		<link>http://monkeyisland.pl/2008/04/26/asking-and-telling/#comment-3760</link>
		<dc:creator><![CDATA[EasyMock and Mockito, a little comparison &#171; Stefan Hendriks&#039; Blog]]></dc:creator>
		<pubDate>Fri, 04 Mar 2011 21:42:14 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=78#comment-3760</guid>
		<description><![CDATA[[...] And of course at the end it all needs to be verified. Which is done by EasyMock.verify. We could even check the outcome. Most of the time you&#8217;re tempted to do so, you had to write the return value anyway. Better test if the return value being returned is the same as the method returns right? I think not. Reason: your intention of your test becomes unclear if you assert this as well. And as a bonus you introduce your tests to be more fragile. The unit test becomes now a collaborator test and a value-based test in one. Mockito makes this distinction very clear. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] And of course at the end it all needs to be verified. Which is done by EasyMock.verify. We could even check the outcome. Most of the time you&#8217;re tempted to do so, you had to write the return value anyway. Better test if the return value being returned is the same as the method returns right? I think not. Reason: your intention of your test becomes unclear if you assert this as well. And as a bonus you introduce your tests to be more fragile. The unit test becomes now a collaborator test and a value-based test in one. Mockito makes this distinction very clear. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Junit &#38;&#38; Mockito &#171; Uno scrittoio digitale &#8230;</title>
		<link>http://monkeyisland.pl/2008/04/26/asking-and-telling/#comment-3654</link>
		<dc:creator><![CDATA[Junit &#38;&#38; Mockito &#171; Uno scrittoio digitale &#8230;]]></dc:creator>
		<pubDate>Wed, 27 Oct 2010 09:50:44 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=78#comment-3654</guid>
		<description><![CDATA[[...] mitico articolo da rileggere ogni tanto [...]]]></description>
		<content:encoded><![CDATA[<p>[...] mitico articolo da rileggere ogni tanto [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szczepiq</title>
		<link>http://monkeyisland.pl/2008/04/26/asking-and-telling/#comment-3292</link>
		<dc:creator><![CDATA[szczepiq]]></dc:creator>
		<pubDate>Sat, 01 Aug 2009 15:13:01 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=78#comment-3292</guid>
		<description><![CDATA[You might be right. 

My reason is somewhere between keeping Mockito not very aggressive and pushing tests to be smarter. Smarter, meaning failing for the &#039;right&#039; reasons. Example: if the functionality is missing, then the failure should somehow point out that... the functionality is missing (e.g. central assertion fails). If the functionality is missing I guess I don&#039;t want a failure like: &#039;you didn&#039;t stub me correctly&#039;. I&#039;d prefer: &#039;this assertion fails because functionality is missing. By the way: this stub was called with wrong arguments.&#039;

Unless I&#039;m wrong :) Anyway, if you use Mockito 1.8.0 check out VerboseMockitoJUnitRunner]]></description>
		<content:encoded><![CDATA[<p>You might be right. </p>
<p>My reason is somewhere between keeping Mockito not very aggressive and pushing tests to be smarter. Smarter, meaning failing for the &#8216;right&#8217; reasons. Example: if the functionality is missing, then the failure should somehow point out that&#8230; the functionality is missing (e.g. central assertion fails). If the functionality is missing I guess I don&#8217;t want a failure like: &#8216;you didn&#8217;t stub me correctly&#8217;. I&#8217;d prefer: &#8216;this assertion fails because functionality is missing. By the way: this stub was called with wrong arguments.&#8217;</p>
<p>Unless I&#8217;m wrong :) Anyway, if you use Mockito 1.8.0 check out VerboseMockitoJUnitRunner</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: philippe</title>
		<link>http://monkeyisland.pl/2008/04/26/asking-and-telling/#comment-3291</link>
		<dc:creator><![CDATA[philippe]]></dc:creator>
		<pubDate>Mon, 27 Jul 2009 13:56:11 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=78#comment-3291</guid>
		<description><![CDATA[Interesting idea about the messages. But why is it that you want them only to show when the test fails?

When can such an error occur?
1) functionality is missing: in that case I would like to see, you stubbed a method but it is not called yet
2) you wrongly stubbed something: in that case I want to see the error too
3) you stubbed something, but it is not needed: an error too please

I might have overlooked something, but I think it is handy if the test would fail on stub configuration errors.]]></description>
		<content:encoded><![CDATA[<p>Interesting idea about the messages. But why is it that you want them only to show when the test fails?</p>
<p>When can such an error occur?<br />
1) functionality is missing: in that case I would like to see, you stubbed a method but it is not called yet<br />
2) you wrongly stubbed something: in that case I want to see the error too<br />
3) you stubbed something, but it is not needed: an error too please</p>
<p>I might have overlooked something, but I think it is handy if the test would fail on stub configuration errors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szczepiq</title>
		<link>http://monkeyisland.pl/2008/04/26/asking-and-telling/#comment-3130</link>
		<dc:creator><![CDATA[szczepiq]]></dc:creator>
		<pubDate>Tue, 12 May 2009 15:04:20 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=78#comment-3130</guid>
		<description><![CDATA[&lt;blockquote&gt;1) invoking a deleteBiggest...() twice instead of once
=&gt; return was correct: deleted obj, but due to a wrong if-block, delete was called again
&lt;/blockquote&gt;

I&#039;m not too worried about this one. I&#039;m putting it in a separate test method that verifies that the biggest is deleted. It&#039;s an interesting behavior and I&#039;m happy to create a specific method that describes it.

&lt;blockquote&gt;2) getting the parameter sequence wrong (creating a 1-way relationsship between 2 obj the wrong way)
=&gt; return of the relation was mixed, so data base and program state did not match anymore&lt;/blockquote&gt;

&lt;blockquote&gt;verify seems paranoid / senseless when testing good code, but I prefer writing 1 more verify to reading 10 lines of ugly code.
&lt;/blockquote&gt;

I agree that if you make a mistake in calling a stubbed method (e.g. wrong args) it&#039;s not going to be immediately visible what&#039;s wrong and some extra debugging might help. I respect you prefer to have a verify() that helps out in this matter. However, there is a feature I&#039;d like to introduce in Mockito that will try to solve this problem. Hear me out let me know what you think :)

I&#039;d like Mockito to provide extra debugging info &lt;strong&gt;only when the test fails&lt;/strong&gt;. Exception message could potentially contain information like: you stubbed this method this way but you called it with different arguments. Or: you stubbed this method but this stub was not really used at all. The interesting part is that I&#039;d like this extra debugging info to be added to any exception, regardless if it&#039;s NullPointerException from the code or AssertionError from the test. Basically, any exception/error that makes the test fail.

I guess if Mockito had this, you wouldn&#039;t need to look for too long at 10 lines of ugly code, neither you would need to verify your stubs, right?]]></description>
		<content:encoded><![CDATA[<blockquote><p>1) invoking a deleteBiggest&#8230;() twice instead of once<br />
=&gt; return was correct: deleted obj, but due to a wrong if-block, delete was called again
</p></blockquote>
<p>I&#8217;m not too worried about this one. I&#8217;m putting it in a separate test method that verifies that the biggest is deleted. It&#8217;s an interesting behavior and I&#8217;m happy to create a specific method that describes it.</p>
<blockquote><p>2) getting the parameter sequence wrong (creating a 1-way relationsship between 2 obj the wrong way)<br />
=&gt; return of the relation was mixed, so data base and program state did not match anymore</p></blockquote>
<blockquote><p>verify seems paranoid / senseless when testing good code, but I prefer writing 1 more verify to reading 10 lines of ugly code.
</p></blockquote>
<p>I agree that if you make a mistake in calling a stubbed method (e.g. wrong args) it&#8217;s not going to be immediately visible what&#8217;s wrong and some extra debugging might help. I respect you prefer to have a verify() that helps out in this matter. However, there is a feature I&#8217;d like to introduce in Mockito that will try to solve this problem. Hear me out let me know what you think :)</p>
<p>I&#8217;d like Mockito to provide extra debugging info <strong>only when the test fails</strong>. Exception message could potentially contain information like: you stubbed this method this way but you called it with different arguments. Or: you stubbed this method but this stub was not really used at all. The interesting part is that I&#8217;d like this extra debugging info to be added to any exception, regardless if it&#8217;s NullPointerException from the code or AssertionError from the test. Basically, any exception/error that makes the test fail.</p>
<p>I guess if Mockito had this, you wouldn&#8217;t need to look for too long at 10 lines of ugly code, neither you would need to verify your stubs, right?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: moebius</title>
		<link>http://monkeyisland.pl/2008/04/26/asking-and-telling/#comment-3129</link>
		<dc:creator><![CDATA[moebius]]></dc:creator>
		<pubDate>Tue, 12 May 2009 14:44:18 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=78#comment-3129</guid>
		<description><![CDATA[@stub XOR verfiy:
I am not sure if this is the point, but consider this example: You write a unit test for a &quot;business logic&quot; class (somewhere between UI and low-level persistence) which uses a DAO. This BL class should use methods of the DAO, depending on your test input. In some cases the parameters will be passed through 1:1, but sometimes these parameters may be altered by the BL class or completely new parameters will be computed. (you dont want to / cannot read the entire source code, but you know the rough specs)

In many cases, assert() on the retrun value will fail, if the method call (of the dao) is wrong, but imho a failed verify is more expressive then a failed assert.

examples:
1) invoking a deleteBiggest...() twice instead of once
=&gt; return was correct: deleted obj, but due to a wrong if-block, delete was called again
2) getting the parameter sequence wrong (creating a 1-way relationsship between 2 obj the wrong way)
=&gt; return of the relation was mixed, so data base and program state did not match anymore

1) no chance in hell finding that w/o verify() or some code coverage tool
2) a more rigrid stub may have uncovered this as well

I know especially 2) is more like additional debugging, but if you need to look into someone else&#039;s code / test it, every little bit helps.

verify seems paranoid / senseless when testing good code, but I prefer writing 1 more verify to reading 10 lines of ugly code.]]></description>
		<content:encoded><![CDATA[<p>@stub XOR verfiy:<br />
I am not sure if this is the point, but consider this example: You write a unit test for a &#8220;business logic&#8221; class (somewhere between UI and low-level persistence) which uses a DAO. This BL class should use methods of the DAO, depending on your test input. In some cases the parameters will be passed through 1:1, but sometimes these parameters may be altered by the BL class or completely new parameters will be computed. (you dont want to / cannot read the entire source code, but you know the rough specs)</p>
<p>In many cases, assert() on the retrun value will fail, if the method call (of the dao) is wrong, but imho a failed verify is more expressive then a failed assert.</p>
<p>examples:<br />
1) invoking a deleteBiggest&#8230;() twice instead of once<br />
=&gt; return was correct: deleted obj, but due to a wrong if-block, delete was called again<br />
2) getting the parameter sequence wrong (creating a 1-way relationsship between 2 obj the wrong way)<br />
=&gt; return of the relation was mixed, so data base and program state did not match anymore</p>
<p>1) no chance in hell finding that w/o verify() or some code coverage tool<br />
2) a more rigrid stub may have uncovered this as well</p>
<p>I know especially 2) is more like additional debugging, but if you need to look into someone else&#8217;s code / test it, every little bit helps.</p>
<p>verify seems paranoid / senseless when testing good code, but I prefer writing 1 more verify to reading 10 lines of ugly code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szczepiq</title>
		<link>http://monkeyisland.pl/2008/04/26/asking-and-telling/#comment-3119</link>
		<dc:creator><![CDATA[szczepiq]]></dc:creator>
		<pubDate>Fri, 17 Apr 2009 12:55:10 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=78#comment-3119</guid>
		<description><![CDATA[&lt;blockquote&gt;I prefer Mockito &lt;/blockquote&gt;

Great!

Mockito docs say: &quot;Although it is possible to verify a stubbed invocation, usually it&#039;s just redundant&quot;. If you have ideas how to make javadocs clearer don&#039;t hesitate to write to our mailing list.]]></description>
		<content:encoded><![CDATA[<blockquote><p>I prefer Mockito </p></blockquote>
<p>Great!</p>
<p>Mockito docs say: &#8220;Although it is possible to verify a stubbed invocation, usually it&#8217;s just redundant&#8221;. If you have ideas how to make javadocs clearer don&#8217;t hesitate to write to our mailing list.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

