Data-driven testing

Peter Hansen peter at
Thu Apr 24 04:41:04 CEST 2003

Aahz wrote:
> Which brings up the question: do the unit-testers here write tests for
> throwaway scripts?

For throwaways, I don't write quite so many tests, and in many cases if 
it's only a "small" throwaway script (e.g. one or two subroutines only, 
plus a little mainline) I will write a test or two for the subroutines 
(because I'm doing TDD, not because I want to have unit tests to make 
sure my script works properly... if you see the distinction) but never
for the mainline.  

Basically, the purpose of the tests is to catch problems you create 
when refactoring, so if you're planning to throw the script away, 
you need the tests only to help you write the code in the first
place.  No, that's two reasons for writing the tests - for refactoring,
and to drive the development.  And to document the requirements and
the API for the code.  There are three reasons... oh, bugger ....

Basically, with a literally throwaway script, you do lose much of
the business value of the tests, so as far as I can see you write 
them only if they truly help you write the code properly, which 
should once you're proficient at TDD and then only sometimes, since
you're a very experienced programmer.  Otherwise, and certainly in some 
cases no matter who you are, they really would be a waste of time.  
IMHO.  Except maybe to help you develop the habits.   _Four_ reasons...


More information about the Python-list mailing list