<?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: Test Everything, No Matter How Simple</title>
	<atom:link href="http://cafe.elharo.com/blogroll/test-everything-no-matter-how-simple/feed/" rel="self" type="application/rss+xml" />
	<link>http://cafe.elharo.com/blogroll/test-everything-no-matter-how-simple/</link>
	<description>Longer than a blog; shorter than a book</description>
	<pubDate>Fri, 21 Nov 2008 17:46:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Elliotte Rusty Harold</title>
		<link>http://cafe.elharo.com/blogroll/test-everything-no-matter-how-simple/#comment-18868</link>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
		<pubDate>Thu, 28 Sep 2006 11:19:00 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/test-everything-no-matter-how-simple/#comment-18868</guid>
		<description>No. &lt;code&gt;NullPointerException&lt;/code&gt; is a special case. See &lt;a href="http://www.amazon.com/exec/obidos/ISBN=0201310058/ref=nosim/cafeaulaitA/" rel="nofollow"&gt;Effective Java&lt;/a&gt;, Item 23 and Item 42. From p. 176, "If a caller passes &lt;code&gt;null&lt;/code&gt; in some parameter for which null values are prohibited, convention dictates that &lt;code&gt;NullPointerException&lt;/code&gt; be thrown rather than &lt;code&gt;illegalArgumentException&lt;/code&gt;."</description>
		<content:encoded><![CDATA[<p>No. <code>NullPointerException</code> is a special case. See <a href="http://www.amazon.com/exec/obidos/ISBN=0201310058/ref=nosim/cafeaulaitA/" onclick="javascript:pageTracker._trackPageview('/outbound/comment/www.amazon.com');" rel="nofollow">Effective Java</a>, Item 23 and Item 42. From p. 176, &#8220;If a caller passes <code>null</code> in some parameter for which null values are prohibited, convention dictates that <code>NullPointerException</code> be thrown rather than <code>illegalArgumentException</code>.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Heine Pedersen</title>
		<link>http://cafe.elharo.com/blogroll/test-everything-no-matter-how-simple/#comment-18805</link>
		<dc:creator>Heine Pedersen</dc:creator>
		<pubDate>Thu, 28 Sep 2006 07:55:10 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/test-everything-no-matter-how-simple/#comment-18805</guid>
		<description>Not to be nitpicking - but shouldn't you throw an IllegalArgumentException instead of a NullPointerException?

From the J2SE API on IllegalArgumentException 
"Thrown to indicate that a method has been passed an illegal or inappropriate argument."</description>
		<content:encoded><![CDATA[<p>Not to be nitpicking - but shouldn&#8217;t you throw an IllegalArgumentException instead of a NullPointerException?</p>
<p>From the J2SE API on IllegalArgumentException<br />
&#8220;Thrown to indicate that a method has been passed an illegal or inappropriate argument.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J. B. Rainsberger</title>
		<link>http://cafe.elharo.com/blogroll/test-everything-no-matter-how-simple/#comment-14433</link>
		<dc:creator>J. B. Rainsberger</dc:creator>
		<pubDate>Sun, 10 Sep 2006 05:31:11 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/test-everything-no-matter-how-simple/#comment-14433</guid>
		<description>I assure you I definitely understand the issue. I simply don't understand your reasoning. Let me try to be very clear. As I read it, you state the following:

1. I found a bug in some code.
2. When I went to fix the bug, I first did it before writing a test, then I stopped myself and decided to write the test.
3. It was in writing the test that I realized I tried to fix the bug in the wrong place.
Therefore, test all code, no matter how simple.

It's that last step that doesn't sit right with me. It seems like a sideways jump, rather than a step.

I agree that when we find a bug, we should write a test to expose the bug before fixing it. Without that, how do we know we fixed it? Even so, I think you conflate two lines of reasoning and use a conclusion from one line to justify a statement in the other.

One line of reasoning regards not fixing bugs until there is a test that fails because of the bug.

Another line of reasoning regards the ROI on testing code that I feel is Too Simple to Break. You think the R is worth the I.

The way I read it, you have concluded that it is worth testing Too Simple to Break code, because a test helped you find and fix a bug in code that wasn't Too Simple to Break: namely setType(). If setType() is supposed to do more than just this.type = type, then it is Complex Enough to Break, and so should absolutely be tested.

So you seem to have used an example of finding a bug in code that is Complex Enough to Break to argue that one should test absolutely everything, including code that is Too Simple to Break. I just don't understand how that reasoning works. I do certainly agree with the notion that by writing a test, you slowed down, thought about what you were doing, then realized you were about to fix the wrong code, but that's generally a good idea anyway.</description>
		<content:encoded><![CDATA[<p>I assure you I definitely understand the issue. I simply don&#8217;t understand your reasoning. Let me try to be very clear. As I read it, you state the following:</p>
<p>1. I found a bug in some code.<br />
2. When I went to fix the bug, I first did it before writing a test, then I stopped myself and decided to write the test.<br />
3. It was in writing the test that I realized I tried to fix the bug in the wrong place.<br />
Therefore, test all code, no matter how simple.</p>
<p>It&#8217;s that last step that doesn&#8217;t sit right with me. It seems like a sideways jump, rather than a step.</p>
<p>I agree that when we find a bug, we should write a test to expose the bug before fixing it. Without that, how do we know we fixed it? Even so, I think you conflate two lines of reasoning and use a conclusion from one line to justify a statement in the other.</p>
<p>One line of reasoning regards not fixing bugs until there is a test that fails because of the bug.</p>
<p>Another line of reasoning regards the ROI on testing code that I feel is Too Simple to Break. You think the R is worth the I.</p>
<p>The way I read it, you have concluded that it is worth testing Too Simple to Break code, because a test helped you find and fix a bug in code that wasn&#8217;t Too Simple to Break: namely setType(). If setType() is supposed to do more than just this.type = type, then it is Complex Enough to Break, and so should absolutely be tested.</p>
<p>So you seem to have used an example of finding a bug in code that is Complex Enough to Break to argue that one should test absolutely everything, including code that is Too Simple to Break. I just don&#8217;t understand how that reasoning works. I do certainly agree with the notion that by writing a test, you slowed down, thought about what you were doing, then realized you were about to fix the wrong code, but that&#8217;s generally a good idea anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elliotte Rusty Harold</title>
		<link>http://cafe.elharo.com/blogroll/test-everything-no-matter-how-simple/#comment-12010</link>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
		<pubDate>Wed, 23 Aug 2006 12:04:24 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/test-everything-no-matter-how-simple/#comment-12010</guid>
		<description>You're not quite understanding the problem. Indeed &lt;code&gt;_setType()&lt;/code&gt; should not be tested directly, because it is not public API. The test should go through the &lt;code&gt;setType()&lt;/code&gt; method instead. That was never the issue.

My point is that my initial "fix" of changing the &lt;code&gt;_setType()&lt;/code&gt; method was incorrect, and writing the test method first helped me see that. When I developed the fix just by looking at the code, I didn't notice that. Viewing the code from the perspective of a client class, rather than the model class, helped me see things differently.</description>
		<content:encoded><![CDATA[<p>You&#8217;re not quite understanding the problem. Indeed <code>_setType()</code> should not be tested directly, because it is not public API. The test should go through the <code>setType()</code> method instead. That was never the issue.</p>
<p>My point is that my initial &#8220;fix&#8221; of changing the <code>_setType()</code> method was incorrect, and writing the test method first helped me see that. When I developed the fix just by looking at the code, I didn&#8217;t notice that. Viewing the code from the perspective of a client class, rather than the model class, helped me see things differently.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J. B. Rainsberger</title>
		<link>http://cafe.elharo.com/blogroll/test-everything-no-matter-how-simple/#comment-11891</link>
		<dc:creator>J. B. Rainsberger</dc:creator>
		<pubDate>Tue, 22 Aug 2006 19:00:03 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/test-everything-no-matter-how-simple/#comment-11891</guid>
		<description>It seems to me the bug is in setType() and not in _setType(), so I would continue to test setType(), as you have done here, and not to test _setType(), as you have done here. In t his case, _setType() remains Too Simple to Break, and indeed, is not broken.</description>
		<content:encoded><![CDATA[<p>It seems to me the bug is in setType() and not in _setType(), so I would continue to test setType(), as you have done here, and not to test _setType(), as you have done here. In t his case, _setType() remains Too Simple to Break, and indeed, is not broken.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
