[Tutor] Where to start with Unit Testing

Mac Ryan quasipedia at gmail.com
Mon Aug 2 05:30:42 CEST 2010


> A different analogy comes to my mind; I once saw two different sets of
> people analyze data.  One did it "by hand":  visually inspecting
> thousands
> of signals herself and typing Y or N to accept or reject each signal.
> The
> other did it with an automated system that accepted or rejected
> signals 
> based on fuzzy logic.  In an important interpretation, the automated
> system 
> was far better, and yet the first scientist was done with her analysis
> and
> accepted for publication before the second team even had the bugs
> worked 
> out of the automated system!  Yes, I think the slow-but-more-proper
> team
> did the more correct thing, but there is something to be said for
> "good
> enough", too (it works for evolution, for example).

Che, from the analogies you made, it looks like you might not have very
clear what Unit Testing is for.

True, UT is a way to automate tests that otherwise you should do
manually (as per your analogy), but the test you automate with UT are
not a "one off" thing (as it is processing the data needed to publish a
paper): depending on the coding philosophy you follow, you might run UT
as often as every couple of hours of coding (as it is in certain agile
programming techniques).

UT is there to give you a tool to prevent regression *when/if you modify
or refactor your code* (which is the norm if you are a professional
programmer), and its advantages grow exponentially with the increase of
complexity of the code and the increase of number of developers working
on the project (it is very easy to break someone's else code... there is
a reason for which "blame" - http://blame.sourceforge.net/ - is called
that way!).

If you are an hobbyist programmer busy on a simple one-off small app,
you may skip UT altogether, manually inspect the behaviour of your
program, and never regret it. 

But if you are writing an e-commerce application that will organise
transaction for millions of euros of revenue monthly, UT is probably the
very first code you will want to commit to your repo.

Mac.

PS: I did not comment on the analogy with evolution, because did not get
the parallelism you were trying to draw. Care to explain?




More information about the Tutor mailing list