Unittests and external data....

Peter Hansen peter at engcorp.com
Fri Mar 21 12:47:24 EST 2003


Mike Meyer wrote:
> 
> Peter Hansen <peter at engcorp.com> writes:
> > Mike Meyer wrote:
> > > While I'm really fond of unit tests, I keep running into problems of
> > > their needing more framework than can easily be captured in the
> > > unittest module.
> > >
> > > For instance, I'm working on a project to interface a data source to
> > > an SQL database. Doing unit tests properly means I need to have
> > > multiple different versions of the source around, or I need to modify
> > > it on the fly. Neither of those is really very practical.
> > Why do you think changing it on the fly is not "very practical"?
> 
> Because the data the test is using is generated on a different - and
> very limited - platform than the one the test is running on. To change
> it on the fly requires going back to the other platform, changing it,
> and then rerunning the export process. This isn't practical for
> automated testing.

Okay, but then I don't understand why the test involves data from a
different platform.  Unit testing (at least XP style) is supposed to be 
very low level and should *not* require external sources of data.

In fact, the data used by the test should be *static*, not changing
from one run to the next.  Following from that, if you have an external
source you should contrive to capture a snapshot of the data at some
point, build that into the test suite, and use that permanently.  Then
the other problem goes away too.  In theory.  Doubtless I'm missing
some important aspect of what you're doing here.

-Peter




More information about the Python-list mailing list