[TIP] real world testing

Ben Finney ben+python at benfinney.id.au
Fri Jul 3 00:00:48 PDT 2009


Ryan Freckleton <ryan.freckleton at gmail.com> writes:

> On Thu, Jul 2, 2009 at 8:02 AM, Matthew Wilson<matt at tplus1.com> wrote:
> > I think about this a lot.  I find I get the best ROI on writing
> > tests when any of these are true:
> >
> > * The need for quality is more important than getting it done
> > quickly.

These two aren't in conflict. The only change in time I can see you get
by avoiding writing a test at all is that you can *stop* earlier; that
is quite different from saying it's *done*. Without some kind of test
written, how can you know when you're done?

Since, therefore, some kind of test has to be performed anyway to know
that completion has been reached, I think it's quicker to do so in an
automated fashion.

> > * I'm not sure exactly how to solve the puzzle yet.  Writing tests
> > clarifies what I need.
> > * I'm happy with an interface but I want to improve the
> > implementation.

Don't these two just describe opposite ends of a spectrum? I agree that
automated unit testing (and other kinds of testing) is good for both of
them, but I don't see how there's any situation not covered by one or
both of these :-)

> > * I'm fixing a bug that is not fast to reproduce manually.

This has come up before, and it is apparently related to the fact that
some people are trying to do CPU-bound test automation of components
that aren't actually running in the CPU. If that describes the situation
you're referring to, I think that means you're beginning your testing at
the wrong level of instrumentation.

Unit testing is best applied when the units are truly loosely-coupled
and well-isolated. Since that describes, IMO, a well-designed system,
then I think each reinforces the other: writing automated unit tests
make it easier to design a system well, and a well-designed system is
easier to write automated unit tests for.

> Maybe I've drank too much testing koolaid (mmm, strawberry!) But I
> find I develop *faster* when I write tests as I'm going along. Much
> faster than my coworkers who don't write tests as they develop.

Ditto.

-- 
 \          “It is well to remember that the entire universe, with one |
  `\   trifling exception, is composed of others.” —John Andrew Holmes |
_o__)                                                                  |
Ben Finney




More information about the testing-in-python mailing list