<?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: should I worry about the unexpected?</title>
	<atom:link href="http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/feed/" rel="self" type="application/rss+xml" />
	<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/</link>
	<description>about software</description>
	<lastBuildDate>Fri, 11 May 2012 11:03:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Uberto</title>
		<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/#comment-3758</link>
		<dc:creator><![CDATA[Uberto]]></dc:creator>
		<pubDate>Tue, 01 Mar 2011 11:32:58 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=92#comment-3758</guid>
		<description><![CDATA[;)

Anyway I have to correct myself, I&#039;m putting a lot of verifyNoMoreInteractions() in my tests and I&#039;m still found them useful.

I&#039;m working with GOOS style, only finding mockito syntax nicer than Jmock. This means I mock mostly interfaces, not classes.

In your examples I find #3 and #4 wrong because I don&#039;t want to compare status but only to tests iterations between objects.

Also if in my tests I feel I need too many verifies, that&#039;s a smell my objects either has too many resp or need a new interface (I in SOLID).]]></description>
		<content:encoded><![CDATA[<p>;)</p>
<p>Anyway I have to correct myself, I&#8217;m putting a lot of verifyNoMoreInteractions() in my tests and I&#8217;m still found them useful.</p>
<p>I&#8217;m working with GOOS style, only finding mockito syntax nicer than Jmock. This means I mock mostly interfaces, not classes.</p>
<p>In your examples I find #3 and #4 wrong because I don&#8217;t want to compare status but only to tests iterations between objects.</p>
<p>Also if in my tests I feel I need too many verifies, that&#8217;s a smell my objects either has too many resp or need a new interface (I in SOLID).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szczepiq</title>
		<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/#comment-3757</link>
		<dc:creator><![CDATA[szczepiq]]></dc:creator>
		<pubDate>Mon, 28 Feb 2011 18:12:58 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=92#comment-3757</guid>
		<description><![CDATA[Hmmm... could work given I also tell the user that &quot;maybe you don&#039;t really need verifyNoMore here?&quot;. 

It&#039;s best to suggest features in our tracker.

Cheers!]]></description>
		<content:encoded><![CDATA[<p>Hmmm&#8230; could work given I also tell the user that &#8220;maybe you don&#8217;t really need verifyNoMore here?&#8221;. </p>
<p>It&#8217;s best to suggest features in our tracker.</p>
<p>Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Uberto</title>
		<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/#comment-3755</link>
		<dc:creator><![CDATA[Uberto]]></dc:creator>
		<pubDate>Sat, 19 Feb 2011 10:42:21 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=92#comment-3755</guid>
		<description><![CDATA[Hi I really like some kind of setup like &quot;verifyNoMoreTell = true&quot; for all my tests.
Also using the simple rule that &quot;void return methods are Tell&quot; would be useful.

Anyway atm I&#039;m not putting a lot of verifyNoMoreInteractions in my tests but I find it very useful when I need to start testing a class which wasn&#039;t under test before.

Would be very nice if there could be a way to let Mockito print out the missing verify, something like:

org.mockito.exceptions.verification.NoInteractionsWanted: 
No interactions wanted here:
-&gt; at xxx.java:42
But found this interaction:
-&gt; at yyy.java:84

maybe you forgot to add a verify?
-&gt; verify(xxx).zzz(any());


I&#039;m also willing to contribute with the code if there&#039;s interest.]]></description>
		<content:encoded><![CDATA[<p>Hi I really like some kind of setup like &#8220;verifyNoMoreTell = true&#8221; for all my tests.<br />
Also using the simple rule that &#8220;void return methods are Tell&#8221; would be useful.</p>
<p>Anyway atm I&#8217;m not putting a lot of verifyNoMoreInteractions in my tests but I find it very useful when I need to start testing a class which wasn&#8217;t under test before.</p>
<p>Would be very nice if there could be a way to let Mockito print out the missing verify, something like:</p>
<p>org.mockito.exceptions.verification.NoInteractionsWanted:<br />
No interactions wanted here:<br />
-&gt; at xxx.java:42<br />
But found this interaction:<br />
-&gt; at yyy.java:84</p>
<p>maybe you forgot to add a verify?<br />
-&gt; verify(xxx).zzz(any());</p>
<p>I&#8217;m also willing to contribute with the code if there&#8217;s interest.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/#comment-3265</link>
		<dc:creator><![CDATA[Anonymous]]></dc:creator>
		<pubDate>Tue, 30 Jun 2009 10:32:41 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=92#comment-3265</guid>
		<description><![CDATA[&gt; If I were about writing mockito again, I would definitely 
&gt; consider making verifyNoMoreInteractions() assert only ‘tell’
&gt; interactions. Any ideas how to fix it without serious impact
&gt; on backwards compatibility?

How &#039;bout: verifyAsk, verifyTell, and verifyNoMoreTell?!?

BTW: Both tests in your example will fail ;)]]></description>
		<content:encoded><![CDATA[<p>&gt; If I were about writing mockito again, I would definitely<br />
&gt; consider making verifyNoMoreInteractions() assert only ‘tell’<br />
&gt; interactions. Any ideas how to fix it without serious impact<br />
&gt; on backwards compatibility?</p>
<p>How &#8217;bout: verifyAsk, verifyTell, and verifyNoMoreTell?!?</p>
<p>BTW: Both tests in your example will fail ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom De Wolf</title>
		<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/#comment-3002</link>
		<dc:creator><![CDATA[Tom De Wolf]]></dc:creator>
		<pubDate>Wed, 22 Oct 2008 10:15:39 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=92#comment-3002</guid>
		<description><![CDATA[I agree that testing the unexpected is important, but that frameworks should not do this by default. You need the choice because sometimes it is not important.]]></description>
		<content:encoded><![CDATA[<p>I agree that testing the unexpected is important, but that frameworks should not do this by default. You need the choice because sometimes it is not important.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szczepiq</title>
		<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/#comment-2998</link>
		<dc:creator><![CDATA[szczepiq]]></dc:creator>
		<pubDate>Tue, 21 Oct 2008 20:37:12 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=92#comment-2998</guid>
		<description><![CDATA[&gt;Then maybe testing the unexpected IS important. It depends on the case at hand I think.

That&#039;s true, maybe testing the unexpected is important. However state testing has been here for years and I haven&#039;t noticed anyone complaining on the fact that junit does not check for unexpected. You can achieve it obviously but it is not &quot;in the framework&quot;.

The way state testing works just feels right to me. If I want to test the unexpected I will be extra explicit and make my test richer. Mocking is different: testing the unexpected is turned on by default. Many times I have to be extra explicit and ignore irrelevant interactions. It makes my tests noisier, not richer...]]></description>
		<content:encoded><![CDATA[<p>&gt;Then maybe testing the unexpected IS important. It depends on the case at hand I think.</p>
<p>That&#8217;s true, maybe testing the unexpected is important. However state testing has been here for years and I haven&#8217;t noticed anyone complaining on the fact that junit does not check for unexpected. You can achieve it obviously but it is not &#8220;in the framework&#8221;.</p>
<p>The way state testing works just feels right to me. If I want to test the unexpected I will be extra explicit and make my test richer. Mocking is different: testing the unexpected is turned on by default. Many times I have to be extra explicit and ignore irrelevant interactions. It makes my tests noisier, not richer&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom De Wolf</title>
		<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/#comment-2995</link>
		<dc:creator><![CDATA[Tom De Wolf]]></dc:creator>
		<pubDate>Fri, 17 Oct 2008 10:31:30 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=92#comment-2995</guid>
		<description><![CDATA[writing verifyNoMoreInteractions to only assert &#039;tell&#039; interactions is difficult because you cannot assume that every method written is only an &#039;ask&#039; or &#039;tell&#039;. Any system includes methods that have a side effect and also return information. Thus a combination of &#039;ask&#039; and &#039;tell&#039; :-) Any void method is only a &#039;tell&#039; method but not any returning method is only an &#039;ask&#039; method. But it should be in the ideal case.

considering upexpected changes to other public state: you can an should write tests that only test changes to certain public state. However, I think that, for each public state there should be one or more tests that test the methods changing that public state. 

Still, one could have a situation where an unexpected change to other public states than the state under test indicates a bug. Then maybe testing the unexpected IS important. It depends on the case at hand I think.]]></description>
		<content:encoded><![CDATA[<p>writing verifyNoMoreInteractions to only assert &#8216;tell&#8217; interactions is difficult because you cannot assume that every method written is only an &#8216;ask&#8217; or &#8216;tell&#8217;. Any system includes methods that have a side effect and also return information. Thus a combination of &#8216;ask&#8217; and &#8216;tell&#8217; :-) Any void method is only a &#8216;tell&#8217; method but not any returning method is only an &#8216;ask&#8217; method. But it should be in the ideal case.</p>
<p>considering upexpected changes to other public state: you can an should write tests that only test changes to certain public state. However, I think that, for each public state there should be one or more tests that test the methods changing that public state. </p>
<p>Still, one could have a situation where an unexpected change to other public states than the state under test indicates a bug. Then maybe testing the unexpected IS important. It depends on the case at hand I think.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szczepiq</title>
		<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/#comment-2994</link>
		<dc:creator><![CDATA[szczepiq]]></dc:creator>
		<pubDate>Thu, 16 Oct 2008 23:11:51 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=92#comment-2994</guid>
		<description><![CDATA[What about a situation where an object does not have any &#039;private&#039; state? Still, I would like to test only certain public state without worrying about unexpected changes to other public state.

&gt;Note, I say ‘maybe’ use verifyNoInteractions because if you consider the difference &gt;between ‘asking’ and ‘telling’ 

Very true. If I were about writing mockito again, I would definitely consider making verifyNoMoreInteractions() assert only &#039;tell&#039; interactions. Any ideas how to fix it without serious impact on backwards compatibility? :)]]></description>
		<content:encoded><![CDATA[<p>What about a situation where an object does not have any &#8216;private&#8217; state? Still, I would like to test only certain public state without worrying about unexpected changes to other public state.</p>
<p>&gt;Note, I say ‘maybe’ use verifyNoInteractions because if you consider the difference &gt;between ‘asking’ and ‘telling’ </p>
<p>Very true. If I were about writing mockito again, I would definitely consider making verifyNoMoreInteractions() assert only &#8216;tell&#8217; interactions. Any ideas how to fix it without serious impact on backwards compatibility? :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom De Wolf</title>
		<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/#comment-2993</link>
		<dc:creator><![CDATA[Tom De Wolf]]></dc:creator>
		<pubDate>Thu, 16 Oct 2008 11:08:08 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=92#comment-2993</guid>
		<description><![CDATA[I share the thought that we should not write verifyNoInteractions everywhere on every mock. But I do see an important difference between state testing and interaction testing. 

Consider a class UnitUnderTest which has state and interacts with AnotherUnit. 

- state testing: we only test state which is accessible in the interface of UnitUnderTest. Internal state, never made public is not to be tested. Hence, state is closely related to encapsulation. And indeed, we do not have to test that for UnitUnderTest no unexpected changes are made to private state.

- interaction testing: in this case interacting with AnotherUnit implies you ask to do some actions to that unit. Thus this affects the behaviour of the application + it crosses the encapsulation boundary. Therefore it should be tested AND maybe also tested that no other interactions happen with that unit. This because other interaction trigger extra behaviour which is not wanted according to the test.

Note, I say &#039;maybe&#039; use verifyNoInteractions because if you consider the difference between &#039;asking&#039; and &#039;telling&#039; (see your other blog entry) then clearly only the telling interactions should be verified and if UnitUnderTest also asks things to AnotherUnit then verifyNoMoreInteractions would imply to also verify the &#039;asking&#039; interactions which we want to avoid.]]></description>
		<content:encoded><![CDATA[<p>I share the thought that we should not write verifyNoInteractions everywhere on every mock. But I do see an important difference between state testing and interaction testing. </p>
<p>Consider a class UnitUnderTest which has state and interacts with AnotherUnit. </p>
<p>- state testing: we only test state which is accessible in the interface of UnitUnderTest. Internal state, never made public is not to be tested. Hence, state is closely related to encapsulation. And indeed, we do not have to test that for UnitUnderTest no unexpected changes are made to private state.</p>
<p>- interaction testing: in this case interacting with AnotherUnit implies you ask to do some actions to that unit. Thus this affects the behaviour of the application + it crosses the encapsulation boundary. Therefore it should be tested AND maybe also tested that no other interactions happen with that unit. This because other interaction trigger extra behaviour which is not wanted according to the test.</p>
<p>Note, I say &#8216;maybe&#8217; use verifyNoInteractions because if you consider the difference between &#8216;asking&#8217; and &#8216;telling&#8217; (see your other blog entry) then clearly only the telling interactions should be verified and if UnitUnderTest also asks things to AnotherUnit then verifyNoMoreInteractions would imply to also verify the &#8216;asking&#8217; interactions which we want to avoid.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hamlet D'Arcy</title>
		<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/#comment-2934</link>
		<dc:creator><![CDATA[Hamlet D'Arcy]]></dc:creator>
		<pubDate>Wed, 16 Jul 2008 16:54:04 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=92#comment-2934</guid>
		<description><![CDATA[Simply put: verifying expectations leads to overspecified and fragile tests. In practice, I&#039;m just as likely to delete and rewrite a test case with failing expectation as I am to update them to work correctly. When I hit someone else&#039;s failing test cases that verify every expectation possible, it simply isn&#039;t worth my time to try to fix them. 

As for the synopsis of &quot;worrying about unexpected may NOT be such a good friend of TDD&quot;...  Heck, it isn&#039;t even a good friend of maintainability! 

My opinion: write side effect free code. Pass in stubs if you must, reverting to spies and mocks only when necessary... and please verify only the things you really care about!]]></description>
		<content:encoded><![CDATA[<p>Simply put: verifying expectations leads to overspecified and fragile tests. In practice, I&#8217;m just as likely to delete and rewrite a test case with failing expectation as I am to update them to work correctly. When I hit someone else&#8217;s failing test cases that verify every expectation possible, it simply isn&#8217;t worth my time to try to fix them. </p>
<p>As for the synopsis of &#8220;worrying about unexpected may NOT be such a good friend of TDD&#8221;&#8230;  Heck, it isn&#8217;t even a good friend of maintainability! </p>
<p>My opinion: write side effect free code. Pass in stubs if you must, reverting to spies and mocks only when necessary&#8230; and please verify only the things you really care about!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

