The Artima Developer Community
Sponsored Link

SuiteRunner Forum
One Time Setup?

9 replies on 1 page. Most recent reply: Feb 19, 2003 7:21 PM by Bill Venners

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 9 replies on 1 page
Jerome Jacobsen

Posts: 3
Nickname: jjacobs
Registered: Jan, 2003

One Time Setup? Posted: Jan 28, 2003 12:28 PM
Reply to this message Reply
Advertisement
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?


Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: One Time Setup? Posted: Jan 28, 2003 3:09 PM
Reply to this message Reply
> 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.

Jerome Jacobsen

Posts: 3
Nickname: jjacobs
Registered: Jan, 2003

Re: One Time Setup? Posted: Jan 29, 2003 7:39 AM
Reply to this message Reply
I have a persistence layer which takes 15-20 seconds to initialize on startup. It uses Toplink which parses XML defining the O/R mappings for my project on startup.

The JUnit way of testing this is to initialize in the setUp method and destroy in the tearDown method. That is, if you want every test to take 20 seconds!

The JUnit purists would argue that I should be doing Indo-testing using mock objects instead of the real Toplink implementation. However I want to test the implementation (e.g. conformance testing to my persistence layer API).

Anyway, the above is an example of why I want oneTimeSetUp and oneTimeTearDown. Maybe this is suiteSetup and suiteTearDown.

Brooke Wilmoth

Posts: 7
Nickname: brooke
Registered: Jan, 2003

Re: One Time Setup? Posted: Jan 29, 2003 4:46 PM
Reply to this message Reply
I have a similar situation to Jerome and could benefit from a one time set up and tear down scenario due to long and complicated initialization, some of which is for a persistence layer also.

Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: One Time Setup? Posted: Jan 30, 2003 2:26 PM
Reply to this message Reply
Thanks for the details. Let me think about that a bit. Right now I'm travelling (writing this in an airport), so my posts will be a bit intermittent.

It sounds like you really do want to pass the same "context" to multiple tests. In other words, you initialize the persistence layer, which results in some kind of object, maybe a database connection? Then you pass that object to each test so it can reuse it.

Does that sound right?

Brooke Wilmoth

Posts: 7
Nickname: brooke
Registered: Jan, 2003

Re: One Time Setup? Posted: Jan 30, 2003 3:58 PM
Reply to this message Reply
Bill,

That is exactly what I need to do. I have been playing with JUnit recently and run into problems with attempting to do this one-time contextual initialization. If Suiterunner could help with this, it would be a lifesaver. Or even if you have an idea about how to accomplish this in general, that would be great.

Thanks,
Brooke

Nagendra

Posts: 3
Nickname: kishan
Registered: Jan, 2003

Re: One Time Setup? Posted: Feb 19, 2003 5:04 PM
Reply to this message Reply
Checkout JTestCase at this URL: http://jtestcase.sourceforge.net/

Nagendra

Posts: 3
Nickname: kishan
Registered: Jan, 2003

Re: One Time Setup? Posted: Feb 19, 2003 5:28 PM
Reply to this message Reply
I meant JFunc not JTestCase. I've been evaluating several unit testing tools lately. Hence the confusion!!.

I apologize for misleading.

Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: One Time Setup? Posted: Feb 19, 2003 7:19 PM
Reply to this message Reply
JFunc is here:

http://jfunc.sourceforge.net/

Thanks for pointing out both of these tools.

Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: One Time Setup? Posted: Feb 19, 2003 7:21 PM
Reply to this message Reply
Sorry I haven't yet posted about passing context to tests. I hope to publish an article on that subject on March 3.

I'll also check into the problems addressed by JFunc and JTestCase, and see if there are ways to do that with Artima SuiteRunner.

Flat View: This topic has 9 replies on 1 page
Topic: Artima SuiteRunner v1.0beta5 Released Previous Topic   Next Topic Topic: Artima SuiteRunner v1.0beta4 Released

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use