Efficient python programming...

Peter Hansen peter at engcorp.com
Sat Jun 8 01:17:37 CEST 2002


holger krekel wrote:
> 
> Peter Hansen wrote:
> > You forgot the even more important first thing for a beginner:
> > get it correct!  The only good way to do this is to write unit
> > tests that prove it.  If you don't have tests, you don't have
> > working code (or how can you prove it?).
> 
> yeah. writing tests is *the way* to go if you want other people use
> your code. Although successfull unittests theoretically don't prove
> anything<wink> they tend to do in reality<doublewink>.

Could you explain why you think unittests don't prove anything 
when they are successful?

Are you pointing out that if you write a test after the code
and the test passes, you have learned almost nothing?  I agree
with that.

With Test-Driven Development, however, you write the test first,
run it immediately, and ensure that it fails.  Only after you
have code that makes it pass are you done.

In this case, making sure the test fails when the code is wrong,
wouldn't you say that the test mostly proves that the code works?

(Not quibbling about the fact you are still not 100% sure...)

-Peter



More information about the Python-list mailing list