Loading ...
Sorry, an error occurred while loading the content.

Re: [XP] Need some help regarding JUnit Testing Pattern

Expand Messages
  • William Pietri
    Hi, David! ... Glad to hear it. If TestNG doesn t solve your problems, there s another option to consider, which is just not using tearDown. If each test (or
    Message 1 of 5 , Sep 19, 2005
    • 0 Attachment
      Hi, David!

      On Sun, 2005-09-18 at 23:09 +0000, David Sokolov wrote:
      > You pretty much got the big picture as to what I'm trying to do.
      > However, this so called "hardware objects"; you are right that I want
      > them to retain their state from test to test, but they need to hold
      > different values for each test group/suite which can be nested.
      > That is one of the problems: I don't know exacly when to tear down that
      > object and re-init it for the next test group. As I said, I've tried doing
      > it by
      > extending TestSetup and overiding setUp/tearDown but I found it difficult
      > to pass on correctly the "tearDown dignal" up the testing tree (for example,
      > finishing one suit might require the re-init of several "hardware objects").
      >
      > Anyway, thanks to Cedric Beust, I'm now aware of TestNG which seems
      > to answer all of my demands so I'm probably going to use it instead of
      > JUnit.

      Glad to hear it.

      If TestNG doesn't solve your problems, there's another option to
      consider, which is just not using tearDown.

      If each test (or each setUp) tells the shared resource what the desired
      state should be, the shared resource can figure out how to get there on
      its own. Then all your performance optimization can live in one object,
      rather than spread out through your collection of tests.

      William

      > Best Regards,
      > David
      >
      >
      > >From: William Pietri <william@...>
      > >Reply-To: extremeprogramming@yahoogroups.com
      > >To: extremeprogramming@yahoogroups.com
      > >Subject: Re: [XP] Need some help regarding JUnit Testing Pattern
      > >Date: Sun, 18 Sep 2005 12:41:12 -0700
      > >
      > >On Sun, 2005-09-18 at 13:37 +0000, ncrdtsuo wrote:
      > > > My problem is that I need to make the setup/tear down code for every
      > > > internal node run only once for all its descendants. I know that it's
      > > > not recommended but in my case it's a necessity: The setup/tear down
      > > > deals with hardware and every action takes too much time comparing to
      > > > the time it takes to run the actuall test methods (the tree leaves).
      > > >
      > > > I thought to make every internal node a singleton and wrap its
      > > > suite in one time setup/tear down code by extending TestSetup and
      > > > overiding setUp() and tearDown() but I'm having all sort of problems
      > > > with that idea.
      > >
      > >If I understand your question rightly, it sounds like you want the
      > >objects representing the hardware to hang around from test to test so
      > >that they can maintain the "yes, I'm initialized" state. Is that right?
      > >
      > >If so, three convenient places to keep longer-lived objects are
      > >
      > > 1. as a static variable
      > > 2. as a thread-local variable
      > > 3. in another process
      > >
      > >The easiest one is the static variable. I wouldn't even bother with
      > >setUp/tearDown; I'd just have a singleton that I talk to everywhere, and
      > >do the initialization when I create the singleton. E.g.:
      > >
      > > public static synchronized MyHardware getInstance() {
      > > if (instance==null) {
      > > instance=new MyHardware();
      > > instance.doExpensiveInitialization();
      > > }
      > > return instance;
      > > }
      > >
      > >
      > >Would that work for you? If not, perhaps you could tell us more about
      > >what came under "all sorts of problems".
      > >
      > >
      > >Regards,
      > >
      > >William
      > >
      > >--
      > >William Pietri <william@...>
      > >
      > >
      > >
      > >To Post a message, send it to: extremeprogramming@...
      > >
      > >To Unsubscribe, send a blank message to:
      > >extremeprogramming-unsubscribe@...
      > >
      > >ad-free courtesy of objectmentor.com
      > >Yahoo! Groups Links
      > >
      > >
      > >
      > >
      > >
      > >
      >
      > _________________________________________________________________
      > Dont just search. Find. Check out the new MSN Search!
      > http://search.msn.click-url.com/go/onm00200636ave/direct/01/
      >
      >
      >
      > To Post a message, send it to: extremeprogramming@...
      >
      > To Unsubscribe, send a blank message to: extremeprogramming-unsubscribe@...
      >
      > ad-free courtesy of objectmentor.com
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
      --
      William Pietri <william@...>
    Your message has been successfully submitted and would be delivered to recipients shortly.