Unittests and external data....

Mike Meyer mwm at mired.org
Sat Mar 22 14:01:06 EST 2003


Peter Hansen <peter at engcorp.com> writes:

> 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.

Because the objects in the program being tested manipulate data from
that other platform. That's the point of the code - to take that data
and make it available via an SQL server. It's not possible to test
without that data, because there's no code that doesn't use that 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.

That's the second alternative I considered - capturing multiple
snapshots of the data at different points. I originally posted this
question hopeing to generate other alternatives for this kind of
testing. And it's generated at least one such alternative - mock
objects.

        Thanks,
        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.




More information about the Python-list mailing list