[issue2241] Additional Flag For Unit-Test Module: There Can Be Only One (Error)
Steve Purcell
report at bugs.python.org
Thu Mar 6 21:32:11 CET 2008
Steve Purcell added the comment:
Hi Brian - thanks for going into some details of your rationale!
You might be surprised to hear that it's indeed possible to make all of
your unit tests mutually independent; check out the area of 'mock
objects'. It turns out to be possible, and indeed desirable once the
"zen" of the technique clicks, to test every class in isolation without
referring to other neighbouring classes. I was surprised by the
enormous effectiveness of this somewhat hardcore technique when I was
forced into it by working with one of the original Mock Object paper
authors. Having already spent years coaching developers in XP
techniques, I thought I was already a testing whiz.
In most real-world cases, though, a class under test will be tested
using its interaction with other separately-tested classes in the
system, and the associated unit tests therefore bear some relation to
one another. It's usually not helpful to divide those classes into
layers that can be tested in order from the lowest layer to the highest,
because classes tend to form clumps rather than layers. When a big
suite of tests is run, failures therefore form clumps too, and often the
underlying programming error is easier to see by looking at the clump
rather than just the first failure. I think this explains why most
people get by without an option like '-o'.
Of course, it often makes sense to have separate test suites for
different areas of the system under test so that they can be run in
isolation. Rather than relying on test naming, you might consider
explicitly building TestSuites that run your test cases in the desired
order.
As for preparing an updated patch, I'll get to it if I get a few
minutes.
All the best from this Brit in Germany.
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2241>
__________________________________
More information about the Python-bugs-list
mailing list