[Tutor] programming exercise in Python

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Aug 9 22:23:04 CEST 2006

> I had the program generate the test cases for me, and then inspected 
> them to verify that they were what I desired.

Hi Kermit,

Ah.  Try not to do that next time.

It's way too easy to be convinced that some test is working by just 
copying the output of the code and looking for reasonable output.  But 
it's much more useful to write out the complete test case without 
preconceptions, without the aid of the code you're trying to test.  This 
works because:

     * You can't cheat yourself.  *grin*

     * Writing out the test cases first can help in writing the
       real function.

Those test cases act as documentation that other people can look at. 
They're a form of specification --- a requirement --- that allows others 
to understand the intent of the function.

More information about the Tutor mailing list