Re: [Pyunit-interest] passing arguments to TestCase constructor through makeSuite
Brought to you by:
purcell
From: Steve P. <ste...@ya...> - 2000-09-20 18:02:40
|
Andrew Wilcox wrote: > In my application, I'm passing some contextual information into my TestCase > constructor with a couple of extra arguments. (I'm using Zope, and the > request information is passed in to me as an argument). This is easy > enough to do, but the makeSuite function only calls the constructor with > the method name. Hi Andrew, Thanks for sharing this. Your example illustrates the complication of testing inside a server environment, where the tests are dependent upon the environment. I'd love to hear more about how you're tackling this. I'm having a lot of the same issues currently, but with the Java and JUnit in the Enhydra application server. My take on things is the following: Usually every TestCase should be instantiable and runnable in its own right, given the right environment, and so it is not recommended to pass in context information. The test case should create its own context in the setUp method. In server environments such as Zope, this often means artificially creating requests from within the test case. A TestRunner subclass customised to the server is often written, and its task of running of tests inside the environment is triggered by a request from outside the server process, e.g. by http. In the case of Zope, this might mean writing a TestRunnerProduct or suchlike. I think there's some information on Zope.org about using PyUnit with Zope, though I don't know how much detail there is. Best wishes, -Steve -- Steve Purcell, Pythangelist "Life must be simple if *I* can do it" -- me |