How to organize test cases with PyUnit
Roy Smith
roy at panix.com
Mon Jul 8 09:15:24 EDT 2002
Peter Hansen <peter at engcorp.com> wrote:
> Is it really important the order the tests are run in?
I'm not sure, but it certainly *feels* like it should be important ;-)
Well, here's an example. I've got a parser which returns a dictionary
of dictionaries. My setUp() method put this in self.tables, then I've
got:
def test101 (self):
'parse() returns a dictionary'
self.assertEqual (type (self.tables), DictType)
def test102 (self):
'parse() returns a dictionary of dictionaries'
for table in self.tables.values():
self.assertEqual (type (table), DictType)
I guess the tests could be run in either order, but it seems better to
do the top-level test first because that mimics how I think about the
problem. If you were to come to me and say, "I've got this complicated
data structure which I think may be corrupted, can you help me figure
out what i did wrong?", I'd probably start at the top and work my way
down.
>From the point of view of "it's done when it passes all the tests", then
yes, I agree with you that the order doesn't matter. But as a
diagnostic tool, it seems like order might be important.
More information about the Python-list
mailing list