testing units in a specific order?
mwm at mired.org
Tue Jan 10 00:50:41 CET 2006
Tim Peters <tim.peters at gmail.com> writes:
> They're run in alphabetical order, sorting on the test methods' names.
> For that reason some people name test methods like 'test_001',
> 'test_002', ..., although unit tests really "shouldn't" case which
> order they get run in.
This seems sort of hard to do with "good" OO design. I.e. - I have
some object foo with the requirement that "foo.setup" be run before
"foo.process". I typically do unit tests to run foo.setup first, and
the test for foo.process assumes that foo.setup has been run.
The alternative would have the setup for "foo.process" run "foo.setup"
as part of the prep. But that assumes that foo.setup worked
properly. To make sure of that, I still need the unit test for
foo.setup to run before the test for foo.process.
I supposed the test would be better if the test of foo.process didn't
expect foo.setup to be run first. But in that case, if foo.setup
fails, running foo.process is only moderatly interesting - a failure
may be a cascade from the failure of setup, and passing the test
may not mean it'll pass if setup actually finishes properly.
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