<?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: Testing Anti-Patterns: Overspecification</title>
	<atom:link href="http://jasonrudolph.com/blog/2008/07/01/testing-anti-patterns-overspecification/feed/" rel="self" type="application/rss+xml" />
	<link>http://jasonrudolph.com/blog/2008/07/01/testing-anti-patterns-overspecification/</link>
	<description>puts Blog.new("nonsense")</description>
	<pubDate>Thu, 04 Dec 2008 19:56:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Jason Rudolph</title>
		<link>http://jasonrudolph.com/blog/2008/07/01/testing-anti-patterns-overspecification/#comment-14384</link>
		<dc:creator>Jason Rudolph</dc:creator>
		<pubDate>Wed, 02 Jul 2008 03:21:47 +0000</pubDate>
		<guid isPermaLink="false">http://jasonrudolph.com/blog/?p=179#comment-14384</guid>
		<description>&lt;p&gt;Hi S.R.,&lt;br/&gt;
You bring up a good point, but there's a difference between a robust set of well-specified tests and a bloated set of overspecified tests.  The example I present above is a bloated and overspecified test.  It's &lt;em&gt;aimed&lt;/em&gt; specifically at testing the controller, and yet it include all sorts of logic about how to create, fetch, and validate a model object.  I certainly want to be testing the model logic I write, but I want to perform those tests in a model test class, not a controller test class.
&lt;br/&gt;&lt;br/&gt;
I like the example you mention regarding the &lt;code&gt;#sum&lt;/code&gt; method.  Let's take a closer look at that scenario.  You argue that the developer could be adversely swayed by looking at the code before writing the test.  There's an easy solution to this problem: just write the tests first. :-) Given a test-driven approach to development, I would have &lt;em&gt;zero&lt;/em&gt; knowledge of the implementation up front.  Therefore, I'd write all the tests necessary to fully exercise a method whose task is to take to values and return their sum:  I'd write a test for a simple case (e.g., &lt;code&gt;sum(2, 1)&lt;/code&gt;), a test with a negative value (e.g., &lt;code&gt;sum(-2, 1)&lt;/code&gt;), a test with two negative values (e.g., &lt;code&gt;sum(-2, -1)&lt;/code&gt;), a test where one value is nil, a test where both values are nil, etc.  After writing each test, I'd implement just enough code to satisfy the test and nothing more.  (Presumably this task would be trivial for simple math like we're talking about here, but the same idea extends to all code.)
&lt;br/&gt;&lt;br/&gt;
I certainly share your desire to make sure my tests are catching bugs, but I can catch those bugs without polluting my controller tests with model-specific assertions.  Take a good unit test suite that keeps your individual building blocks (e.g., models, controllers, library classes) in check, and couple it with a few good integration tests to make sure they all work together, and you've got a good set of developer tests to support your continuing development efforts.
&lt;br/&gt;&lt;br/&gt;
I hope this helps.
&lt;br/&gt;&lt;br/&gt;
Cheers,&lt;br/&gt;
Jason&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi S.R.,<br />
You bring up a good point, but there&#8217;s a difference between a robust set of well-specified tests and a bloated set of overspecified tests.  The example I present above is a bloated and overspecified test.  It&#8217;s <em>aimed</em> specifically at testing the controller, and yet it include all sorts of logic about how to create, fetch, and validate a model object.  I certainly want to be testing the model logic I write, but I want to perform those tests in a model test class, not a controller test class.
<br /><br />
I like the example you mention regarding the <code>#sum</code> method.  Let&#8217;s take a closer look at that scenario.  You argue that the developer could be adversely swayed by looking at the code before writing the test.  There&#8217;s an easy solution to this problem: just write the tests first. <img src='http://jasonrudolph.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> Given a test-driven approach to development, I would have <em>zero</em> knowledge of the implementation up front.  Therefore, I&#8217;d write all the tests necessary to fully exercise a method whose task is to take to values and return their sum:  I&#8217;d write a test for a simple case (e.g., <code>sum(2, 1)</code>), a test with a negative value (e.g., <code>sum(-2, 1)</code>), a test with two negative values (e.g., <code>sum(-2, -1)</code>), a test where one value is nil, a test where both values are nil, etc.  After writing each test, I&#8217;d implement just enough code to satisfy the test and nothing more.  (Presumably this task would be trivial for simple math like we&#8217;re talking about here, but the same idea extends to all code.)
<br /><br />
I certainly share your desire to make sure my tests are catching bugs, but I can catch those bugs without polluting my controller tests with model-specific assertions.  Take a good unit test suite that keeps your individual building blocks (e.g., models, controllers, library classes) in check, and couple it with a few good integration tests to make sure they all work together, and you&#8217;ve got a good set of developer tests to support your continuing development efforts.
<br /><br />
I hope this helps.
<br /><br />
Cheers,<br />
Jason</p>]]></content:encoded>
	</item>
	<item>
		<title>By: S.R.</title>
		<link>http://jasonrudolph.com/blog/2008/07/01/testing-anti-patterns-overspecification/#comment-14381</link>
		<dc:creator>S.R.</dc:creator>
		<pubDate>Tue, 01 Jul 2008 15:30:48 +0000</pubDate>
		<guid isPermaLink="false">http://jasonrudolph.com/blog/?p=179#comment-14381</guid>
		<description>&lt;p&gt;There is one thing to point out about overspecificated approach - it doesn't rely on any knowledge about main code and therefore it will potentially find more bugs. &lt;/p&gt;

&lt;p&gt;Example: &lt;/p&gt;

&lt;p&gt;def sum 
  a - b
end &lt;/p&gt;

&lt;p&gt;Looking in the code test engineer would say : "ah , it does a MINUS b so my test case would be: "&lt;/p&gt;

&lt;p&gt;def test_sum
  assert sum(2 , 1)  == 1
end &lt;/p&gt;

&lt;p&gt;This is of cause an exaggeration  but I can totally see that happening in more complicated cases.&lt;/p&gt;

&lt;p&gt;I'd be interested to know your opinion on this, thanks.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>There is one thing to point out about overspecificated approach - it doesn&#8217;t rely on any knowledge about main code and therefore it will potentially find more bugs. </p>

<p>Example: </p>

<p>def sum 
  a - b
end </p>

<p>Looking in the code test engineer would say : &#8220;ah , it does a MINUS b so my test case would be: &#8220;</p>

<p>def test_sum
  assert sum(2 , 1)  == 1
end </p>

<p>This is of cause an exaggeration  but I can totally see that happening in more complicated cases.</p>

<p>I&#8217;d be interested to know your opinion on this, thanks.</p>]]></content:encoded>
	</item>
</channel>
</rss>
