Art of Unit Testing
Paul Moore
paul.moore at uk.origin-it.com
Fri Aug 17 11:59:15 EDT 2001
On Fri, 17 Aug 2001 15:41:12 +0200, "robin and jim" <robinjim at earthlink.net>
wrote:
>You are quite correct (according to my version of the documentation -- and
>in my experience with using the tool); setUp and tearDown are called for
>each test so you always start and end from a known state. <wink>
I'd argue that if you want to do setup and teardown actions for each
individual test, you can code the actions in the test. But there's no way to
code a setup for a series of tests. For example, in a database application,
you may want to create a connection in setUp(), run a series of queries in
tests, and then close the connection in tearDown(). Creating and closing a
connection per test could well be an unacceptable overhead. To my way of
thinking, this is the common case (of setup/teardown actions), and should be
easy to do. Setup and teardown actions which have such a low overhead as to be
OK to do for each test would seem to be less common. (Indeed, that's how the
docs describe setUp and tearDown, as high-overhead actions, IIRC.)
Paul.
More information about the Python-list
mailing list