<?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: Copying and pasting tests</title>
	<atom:link href="http://www.markhneedham.com/blog/2009/09/22/tdd-copying-and-pasting-tests/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2009/09/22/tdd-copying-and-pasting-tests/</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: Jeremy Gray</title>
		<link>http://www.markhneedham.com/blog/2009/09/22/tdd-copying-and-pasting-tests/comment-page-1/#comment-22944</link>
		<dc:creator>Jeremy Gray</dc:creator>
		<pubDate>Thu, 24 Sep 2009 05:30:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1669#comment-22944</guid>
		<description>After automating unit tests for some six-odd years now, I think I can safely say the following:

There are only two kinds of safely-reusable code when it comes to tests. The first is setup/teardown code that is used for multiple tests within a single fixture, and that is as far as that code&#039;s reuse goes. The second is standardized test object instantiation code that can be factored into formal (and very-carefully-maintained!) Object Mothers.

Trying to reuse anything else has always resulted in test code that is reused and then modified for the sake of one test such that it causes another test (or a number of tests) to no longer operate correctly. Such impacted tests have a nasty tendency to then either still pass when they should have started failing or to start failing when they should have kept passing. Diagnosing such situations has usually proven a more expensive problem than the duplication which is its alternative.

I&#039;ve even given the boot to test base classes with setup/teardown behavior that is effectively shared by derived test classes. These too have more often than not created the same issues as any other reuse outside of the two types I mentioned, even though one might be tempted to consider base class setup/teardown to be among the former kind of safely-reusable test code. I don&#039;t even count that as safe any more.</description>
		<content:encoded><![CDATA[<p>After automating unit tests for some six-odd years now, I think I can safely say the following:</p>
<p>There are only two kinds of safely-reusable code when it comes to tests. The first is setup/teardown code that is used for multiple tests within a single fixture, and that is as far as that code&#8217;s reuse goes. The second is standardized test object instantiation code that can be factored into formal (and very-carefully-maintained!) Object Mothers.</p>
<p>Trying to reuse anything else has always resulted in test code that is reused and then modified for the sake of one test such that it causes another test (or a number of tests) to no longer operate correctly. Such impacted tests have a nasty tendency to then either still pass when they should have started failing or to start failing when they should have kept passing. Diagnosing such situations has usually proven a more expensive problem than the duplication which is its alternative.</p>
<p>I&#8217;ve even given the boot to test base classes with setup/teardown behavior that is effectively shared by derived test classes. These too have more often than not created the same issues as any other reuse outside of the two types I mentioned, even though one might be tempted to consider base class setup/teardown to be among the former kind of safely-reusable test code. I don&#8217;t even count that as safe any more.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Desmarais</title>
		<link>http://www.markhneedham.com/blog/2009/09/22/tdd-copying-and-pasting-tests/comment-page-1/#comment-22894</link>
		<dc:creator>Chris Desmarais</dc:creator>
		<pubDate>Tue, 22 Sep 2009 22:25:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1669#comment-22894</guid>
		<description>Factored test code... is code.

And it needs its own tests.

Once, I made that realization things pretty much fell into place for me. 

If you have tests that have a lot of refactored code, then create a test framework and treat it like you would other solution code.

With that realization:
- copy test code if it isn&#039;t worth the effort of building a properly developed framework
- if it is worth the effort then readability is much better. You have tests that explain the purpose of the code: you have the same support you have for the rest of your solution code.</description>
		<content:encoded><![CDATA[<p>Factored test code&#8230; is code.</p>
<p>And it needs its own tests.</p>
<p>Once, I made that realization things pretty much fell into place for me. </p>
<p>If you have tests that have a lot of refactored code, then create a test framework and treat it like you would other solution code.</p>
<p>With that realization:<br />
- copy test code if it isn&#8217;t worth the effort of building a properly developed framework<br />
- if it is worth the effort then readability is much better. You have tests that explain the purpose of the code: you have the same support you have for the rest of your solution code.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

