<?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/"
		>
<channel>
	<title>Comments on: TDD: Testing sub classes</title>
	<atom:link href="http://www.markhneedham.com/blog/2009/09/13/tdd-testing-sub-classes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2009/09/13/tdd-testing-sub-classes/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Sat, 11 Feb 2012 23:17:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: TDD: Testing with generic abstract classes at Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/09/13/tdd-testing-sub-classes/comment-page-1/#comment-22676</link>
		<dc:creator>TDD: Testing with generic abstract classes at Mark Needham</dc:creator>
		<pubDate>Thu, 17 Sep 2009 14:41:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1635#comment-22676</guid>
		<description>[...] a post I wrote earlier in the week I described a dilemma we were having testing some code which made use of abstract classes and Perryn Fowler, Liz Keogh and Pat Maddox pointed out that a useful approach for this problem [...]</description>
		<content:encoded><![CDATA[<p>[...] a post I wrote earlier in the week I described a dilemma we were having testing some code which made use of abstract classes and Perryn Fowler, Liz Keogh and Pat Maddox pointed out that a useful approach for this problem [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pat Maddox</title>
		<link>http://www.markhneedham.com/blog/2009/09/13/tdd-testing-sub-classes/comment-page-1/#comment-22653</link>
		<dc:creator>Pat Maddox</dc:creator>
		<pubDate>Wed, 16 Sep 2009 21:49:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1635#comment-22653</guid>
		<description>I think what you want is AbstractTestCase which I first read about in JB Rainsberger&#039;s &quot;JUnit Recipes.&quot;  Take a look at http://c2.com/cgi-bin/wiki?AbstractTestCases</description>
		<content:encoded><![CDATA[<p>I think what you want is AbstractTestCase which I first read about in JB Rainsberger&#8217;s &#8220;JUnit Recipes.&#8221;  Take a look at <a href="http://c2.com/cgi-bin/wiki?AbstractTestCases" rel="nofollow">http://c2.com/cgi-bin/wiki?AbstractTestCases</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tobias</title>
		<link>http://www.markhneedham.com/blog/2009/09/13/tdd-testing-sub-classes/comment-page-1/#comment-22596</link>
		<dc:creator>Tobias</dc:creator>
		<pubDate>Tue, 15 Sep 2009 12:31:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1635#comment-22596</guid>
		<description>You could use something like parametrized test (PEX) or an data-based test.

public TestBlabla(AbstractBaseClass classToTest)
{
... 
}
an the input for classToTest are the subclasses.</description>
		<content:encoded><![CDATA[<p>You could use something like parametrized test (PEX) or an data-based test.</p>
<p>public TestBlabla(AbstractBaseClass classToTest)<br />
{<br />
&#8230;<br />
}<br />
an the input for classToTest are the subclasses.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/09/13/tdd-testing-sub-classes/comment-page-1/#comment-22530</link>
		<dc:creator>Mark Needham</dc:creator>
		<pubDate>Mon, 14 Sep 2009 08:26:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1635#comment-22530</guid>
		<description>@Liz, @Perryn - I like that idea of having the test hierarchy matching the code, sounds like it&#039;d work out well - I&#039;ve not come across that approach before, thanks for sharing. 

@Perryn - yeh I was wondering whether the struggling was deserved for using inheritance as well :-D Might actually have been better off using composition.</description>
		<content:encoded><![CDATA[<p>@Liz, @Perryn &#8211; I like that idea of having the test hierarchy matching the code, sounds like it&#8217;d work out well &#8211; I&#8217;ve not come across that approach before, thanks for sharing. </p>
<p>@Perryn &#8211; yeh I was wondering whether the struggling was deserved for using inheritance as well <img src='http://www.markhneedham.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' />  Might actually have been better off using composition.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Liz Keogh</title>
		<link>http://www.markhneedham.com/blog/2009/09/13/tdd-testing-sub-classes/comment-page-1/#comment-22529</link>
		<dc:creator>Liz Keogh</dc:creator>
		<pubDate>Mon, 14 Sep 2009 08:20:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1635#comment-22529</guid>
		<description>Hi Mark,

If I ever create abstract classes, I tend to have a test hierarchy that mirrors them.

So if, for instance I have three classes called:
Animal
Cat
Dog

I&#039;ll create three tests:
abstract AnimalTest
CatTest extends AnimalTest
DogTest extends AnimalTest

(If necessary, I change these names so that whatever build I&#039;m using doesn&#039;t pick up the animal test).

The AnimalTest describes the behaviour that&#039;s common to all animals, and uses an abstract method to create the animal. The CatTest and DogTest then override this method.

This describes the common behaviour quite well, while ensuring that both the Cat and Dog carry out their respective responsibilities here.

The methods in the abstract AnimalTest are never run on their own, only as a component of the other two.</description>
		<content:encoded><![CDATA[<p>Hi Mark,</p>
<p>If I ever create abstract classes, I tend to have a test hierarchy that mirrors them.</p>
<p>So if, for instance I have three classes called:<br />
Animal<br />
Cat<br />
Dog</p>
<p>I&#8217;ll create three tests:<br />
abstract AnimalTest<br />
CatTest extends AnimalTest<br />
DogTest extends AnimalTest</p>
<p>(If necessary, I change these names so that whatever build I&#8217;m using doesn&#8217;t pick up the animal test).</p>
<p>The AnimalTest describes the behaviour that&#8217;s common to all animals, and uses an abstract method to create the animal. The CatTest and DogTest then override this method.</p>
<p>This describes the common behaviour quite well, while ensuring that both the Cat and Dog carry out their respective responsibilities here.</p>
<p>The methods in the abstract AnimalTest are never run on their own, only as a component of the other two.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Perryn Fowler</title>
		<link>http://www.markhneedham.com/blog/2009/09/13/tdd-testing-sub-classes/comment-page-1/#comment-22528</link>
		<dc:creator>Perryn Fowler</dc:creator>
		<pubDate>Mon, 14 Sep 2009 07:01:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1635#comment-22528</guid>
		<description>two more options

1) use composition instead of inheritance ;)

2) If you must use inheritance, use it in your tests too. Create an abstract *test* class that tests the similar behaviour and then extend that class for each of your tests. You would then break three tests with a change but you can fix them all in one place.</description>
		<content:encoded><![CDATA[<p>two more options</p>
<p>1) use composition instead of inheritance <img src='http://www.markhneedham.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>2) If you must use inheritance, use it in your tests too. Create an abstract *test* class that tests the similar behaviour and then extend that class for each of your tests. You would then break three tests with a change but you can fix them all in one place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tweets that mention TDD: Testing sub classes at Mark Needham -- Topsy.com</title>
		<link>http://www.markhneedham.com/blog/2009/09/13/tdd-testing-sub-classes/comment-page-1/#comment-22510</link>
		<dc:creator>Tweets that mention TDD: Testing sub classes at Mark Needham -- Topsy.com</dc:creator>
		<pubDate>Sun, 13 Sep 2009 21:36:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1635#comment-22510</guid>
		<description>[...] This post was mentioned on Twitter by planettw. planettw said: Mark Needham: TDD: Testing sub classes: We ran into another interesting testing dilemma while refactoring the vi.. http://bit.ly/1QGzUt [...]</description>
		<content:encoded><![CDATA[<p>[...] This post was mentioned on Twitter by planettw. planettw said: Mark Needham: TDD: Testing sub classes: We ran into another interesting testing dilemma while refactoring the vi.. <a href="http://bit.ly/1QGzUt" rel="nofollow">http://bit.ly/1QGzUt</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/09/13/tdd-testing-sub-classes/comment-page-1/#comment-22507</link>
		<dc:creator>Mark Needham</dc:creator>
		<pubDate>Sun, 13 Sep 2009 21:09:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1635#comment-22507</guid>
		<description>@Leonardo/Jeremy - I was talking with my colleague Liz about this and she suggested the test specific class as well. 

In .NET you would have to create an actual class to do it which is not quite as clean as in Java but it would still do the job. 

I had written that option off because it feels kinda nasty though since that class your now testing is there just to help testing.

Maybe it&#039;s just the punishment you get for using abstract classes :-D</description>
		<content:encoded><![CDATA[<p>@Leonardo/Jeremy &#8211; I was talking with my colleague Liz about this and she suggested the test specific class as well. </p>
<p>In .NET you would have to create an actual class to do it which is not quite as clean as in Java but it would still do the job. </p>
<p>I had written that option off because it feels kinda nasty though since that class your now testing is there just to help testing.</p>
<p>Maybe it&#8217;s just the punishment you get for using abstract classes <img src='http://www.markhneedham.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Leonardo Borges</title>
		<link>http://www.markhneedham.com/blog/2009/09/13/tdd-testing-sub-classes/comment-page-1/#comment-22501</link>
		<dc:creator>Leonardo Borges</dc:creator>
		<pubDate>Sun, 13 Sep 2009 17:22:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1635#comment-22501</guid>
		<description>We ran into the same kind of dilemma (in Java, though) and our approach was to have an anonymous class that inherits from your abstract parent, making it possible to test it in isolation and without the need to know about the subclasses. 

I don&#039;t work with .NET though, so I&#039;m not sure if such thing would be possible in your case.</description>
		<content:encoded><![CDATA[<p>We ran into the same kind of dilemma (in Java, though) and our approach was to have an anonymous class that inherits from your abstract parent, making it possible to test it in isolation and without the need to know about the subclasses. </p>
<p>I don&#8217;t work with .NET though, so I&#8217;m not sure if such thing would be possible in your case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy Gray</title>
		<link>http://www.markhneedham.com/blog/2009/09/13/tdd-testing-sub-classes/comment-page-1/#comment-22499</link>
		<dc:creator>Jeremy Gray</dc:creator>
		<pubDate>Sun, 13 Sep 2009 15:42:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1635#comment-22499</guid>
		<description>You are right, though, that neither option feels all that great but that&#039;s just the nature of abstract classes. :) / :(</description>
		<content:encoded><![CDATA[<p>You are right, though, that neither option feels all that great but that&#8217;s just the nature of abstract classes. <img src='http://www.markhneedham.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  / <img src='http://www.markhneedham.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

