|
|
Re: One Time Setup?
|
Posted: Jan 28, 2003 3:09 PM
|
|
> One of the controversial but frequent requests of JUnit is > an easy way to do one-time setup. One-time setup being a > setUp method that runs only once for N tests. The gurus > say it is bad. I think it is practical. What are your > opinions? > > Also, does SuiteRunner have built-in support for one-time > setup?
We do not have specific support for one-time setup, but we don't disallow it either.
I suspect you are talking about a specific way to pass context into a test. I may not understand what you are suggesting, but we definitely thought about how to pass context (such as a database connection) to all Suites taking part in a test run.
Basically, we decided that there were lots of different ways to pass context in, and that none of them was the obvious choice. So we made sure all were possible (and none were supported directly in the API). Matt suggested one way in his reply to your News & Ideas post, which is pass a context object to a suite constructor. Other ways are:
1. Have every Suite subclass a Suite that somehow gets the context, and offers protected methods that the subclasses can use to get at the context. 2. Expose a method on Suites that takes the context object and call it before you call execute. This is what I did when in the signature test API, which I haven't yet released. 3. Grab context information from properties. 4. Grab context information (text or objects) from a file.
And so on.
I plan an article in the coming weeks that talks about this issue. We'd appreciate any input as to specific needs you have so we can better understand the problem to solve.
|
|