[Zope3-dev] XP Jargon?

Casey Duncan casey at zope.com
Wed Jan 28 11:33:12 EST 2004


On Wed, 28 Jan 2004 10:55:05 -0500
Jim Fulton <jim at zope.com> wrote:

> Tres has been correcting me on my XP jargon.  I thought I'd share
> the definitions with everyone, and give Tres another opportunity
> to correct me. :)
> 
> Unit tests -- Tests that test one thing at the lowest level.
> 
>     A unit test suite should test one component or class. Ideally,
>     a test should test a minimal interaction, although, we often
>     compromise on this.
> 
>     Many of our so-called unit tests are really integration tests.
>     Often a component depends on a number of other components to
>     do it's work, and tests require significant setup. Sometimes,
>     this is unavoidable.  But I'm learning, over time, that, with
>     care, we often can avoid a lot of setup, either using scaffolding
>     or by being careful just to test components in isolation.
> 
>     A good example of this, imo are the ZODB tests. To test
>     persistence, we have often fallen into the trap of creating
>     databases and storing objects in the databases and making sure we
>     can load them, look at their state, and so on.  OTOH, on occasion,
>     we've managed to get things right. I'm especially proud of
>     persistence.tests.test_persistence.
> 
>     I'm not religious on this issue, but I've found that adhering to
>     the principal of *only* testing one thing can make writing tests
>     simpler and makes the tests more readable.

Also, what is a unit test depends on your point of view. For instance,
what is a unit test of my application, is probably a functional test of
Python if not of the operating system.

I do find it useful to keep each unit test method as specific as
possible. Resist the temptation to test multiple behaviors (no matter
how trivial) in a single unit test method. I'm not sure how this applies
to doctest, but I'm sure it can.

-Casey



More information about the Zope3-dev mailing list