RE: Using refactoring to make code more testable Re: [refactoring] Using refactoring to make code more testable

Michael Charland <[email protected]>
Newsgroups gmane.comp.programming.refactoring
Message-ID <[email protected]>
Along similar lines, how do i get people to add tests? Most of the people I work with do not add any unit tests when submitting new code or fixing old bugs. It's a pretty generic question, but any approaches would help.

Thx

To: [email protected]
From: [email protected]
Date: Mon, 12 Oct 2009 14:41:44 +0100
Subject: Re: [refactoring] Using refactoring to make code more testable Re: [refactoring] Using refactoring to make code more testable















 




    
                  

On 11 Oct 2009, at 20:48, Richard wrote:

[snip]

> Don't write tests just for the sake of writing tests, particularly on

> legacy code.  The changes you need to make to legacy code in order to

> make it testable can just as likely introduce defects as they will

> make the code testable.

[snip]



In addition it's been my experience that folk who just add tests for  

the sake of adding tests end up with a very fragile test suite -  

because they have to add a bunch of extra infrastructure to the test  

suite to deal with the non-TDD code the tests tend to produce a lot of  

false-fails. This is especially harmful when you're trying to  

introduce tests into a team coz people quickly stop trusting the tests.



> If you have defects to fix in that legacy code, then do traditional

> debugging to find the location of the fault and then do a minimal

> amount of decoupling around the fault so you can write a failing test,

> fix the fault and get a passing test.  Leave the rest alone.



That's what I'd do too. With maybe a few story-level tests on the top  

if I thought they'd have any long term value.



Adrian



-- 

http://quietstars.com  -  twitter.com/adrianh  -  delicious.com/adrianh





 

      

    
    
	
	
	
	


	


	
	 		 	   		  
_________________________________________________________________
Click less, chat more: Messenger on MSN.ca
http://go.microsoft.com/?linkid=9677404

[Non-text portions of this message have been removed]



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/refactoring/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.