<?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>Thu, 11 Mar 2010 17:47:47 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Anonymous</title>
		<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/#comment-3265</link>
		<dc:creator>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>&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 <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </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>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>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>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>&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>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>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; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  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>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>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? <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </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>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>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>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>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>
	<item>
		<title>By: Tomek Kaczanowski</title>
		<link>http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/#comment-2933</link>
		<dc:creator>Tomek Kaczanowski</dc:creator>
		<pubDate>Sun, 13 Jul 2008 20:47:02 +0000</pubDate>
		<guid isPermaLink="false">http://szczepiq.wordpress.com/?p=92#comment-2933</guid>
		<description>&quot;and other method on the reader should be called&quot;
you probably meant:
&quot;and NO other method on the reader should be called&quot;

cheers
Tomek Kaczanowski</description>
		<content:encoded><![CDATA[<p>&#8220;and other method on the reader should be called&#8221;<br />
you probably meant:<br />
&#8220;and NO other method on the reader should be called&#8221;</p>
<p>cheers<br />
Tomek Kaczanowski</p>
]]></content:encoded>
	</item>
</channel>
</rss>
