[TIP] Column questions.

Pete pfein at pobox.com
Wed Jul 23 17:16:18 PDT 2008


On Jul 23, 2008, at 5:17 PM, Andrew Dalke wrote:

> Laura Creighton:
>> Should I really write my tests first?  Why?
>
> Sub-question:
>
>   Does writing the tests first discourage API modification?
>
> I've noticed when I try to write tests-first it's very
> annoying because after I have an idea of how the system
> should hang together, I rewrite the API to fit that more
> appropriately, which means I spend time rewriting my tests.
> I tend to iterate API changes, which means I spend a lot
> of time updating test code.  I end up not wanting to make
> changes because there's already code which depends on
> the API.

I'll go further and say that I often have *no* idea what the API's  
gonna look like until I start typing it out.  Writing the tests  
beforehand just doesn't work for my brain.  Instead of writing my  
tests first, I tend to write them early.  Early here means "after I  
think the module is roughly done", as opposed to late, which would be  
after the entire project is done.  The tests then evolve along with  
the code.

FWIW, I initially found myself put off by the idea of testing entirely  
b/c of the volume of the Tests First Or Die! crowd.  There's more than  
one way to do it, folks.

--Pete



More information about the testing-in-python mailing list