[Tutor] IDEs

Alan Gauld alan.gauld at btinternet.com
Wed Nov 24 02:15:48 CET 2010


"Josep M. Fontana" <josep.m.fontana at gmail.com> wrote

>> Also, I'm a big believer in test-driven development. I must admit 
>> though I'm

> Does anybody know of any good reference on testing? How do you 
> develop
> tests for functions?

The basic idea in testing is to try to break your code. Try to think
of every kind of evil input that could possibly come along and see
if your code survives. In amongst all of that you should have a
some valid values too, and know what to expect as out put.

But if you write a function like square(x) you should test it with
inputs like a large negative and large positive value, zero,
complex numbers, floats(both huge and small),
sequences(vectors), and expect all of these to produce
meaningful results. You should also check that it handles
input like strings, booleans, classes and objects (both
with and without __mul__ defined), and anything else
you can think of.

Test Driven Development tends to focus on the more normal inputs
in my experience, but done properly your test code will usually
be bigger than your production code. In a recent project that we
completed we had 600k lines of production code and over a
million lines of test code.

And we still wound up with over 50 reported bugs during Beta test...
But that was much better than the 2000 bugs on an earlier project :-)
But testing is hard.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/






More information about the Tutor mailing list