Peter Scott wrote:
> On Thu, 06 Oct 2005 05:42:59 -0400, Tom Allison wrote:
> 
>>>So make tests that just run the scripts and then examine the outputs. 
>>>If there are unwanted side effects you can't undo from the test then
>>>you need to modify the script in some way.
>>
>>Is this where 'do' comes into use?
> 
> 
> No, I'd use 'system'.  Otherwise the script will be affecting the calling
> environment in ways I'm not supposed to have to find out about with black
> box testing.
> 
> 
>>>This is why writing the tests *before* writing the code makes life so
>>>much easier.  Still, that's hindsight.
>>
>>um...  I have one problem with that.
>>I often don't know what the script is supposed to actually do until I'm
>>already writing it.  Most of these are variations on a theme of log
>>analysis or data mining.
> 
> 
> At least one well known person has said the same thing... but he appears
> to be in a minority.  Personally, unless you're doing the programming
> equivalent of doodling, I can't see how you can write something before
> knowing what it does.  Even if you only formulate the idea a moment before
> writing the code, the idea still precedes the code.
> 

This IMHO is a key to the whole test first. Write all of the tests you
can ahead of time, that doesn't mean every tiny single unit test that
you will ever have has to exist up front. Maybe it is just a unit to
test whether your script exits true or not. The key here for me is that
it gets me into the mindset and guarantees I have a testing harness that
more tests can be added to, once I know what they should be.

> Yes, if you're doing a lot of iterative development, you may change the
> public interface that testing uses and have to rewrite the tests.  That's
> the biggest problem I have with test-first.  But I find it well worth it,
> because if I were to wait until the code was stable, I'd never have any
> tests.  Test-first encourages me to think about my public interfaces in a
> good way.
> 

Right. It takes more time to write the individual code upfront, but it
should save time in aggregate because if you have accurate tests then
making additions/changes in the future will be faster (read: safer).

Now if I could just find someplace that actually does this....

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to