ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "P. Fleury" <fle...@users.sourceforge.net>
Subject Re: JUnit: setUp() method called multiple times ?
Date Thu, 03 Oct 2002 09:49:36 GMT
Erik Hatcher wrote:

> Correct.  This is just the way JUnit works (regardless of it being run 
> from Ant or otherwise).  setUp(), testXXX, tearDown().... setUp(), 
> testZZZ(), tearDown() - that is the JUnit-way, call setUp(), then a 
> test method, then tearDown() repeatedly.
>
>     Erik
>
Mmm. Well, if in my class, I have 3 test functions which needs some 
object to be initialized to run properly. Now it takes a looong time to 
setup that object, so in the current situation, if my class is

class MyBigTest {
    protected void setUp() {
     // long creation of object
     MyObject obj= ...;
    }

    public void testFunction1() { /* use obj */ }
    public void testFunction2() { /* use obj */ }
    public void testFunction3() { /* use obj */ }

}

and if I create a TestSuite giving it the MyBigTest.class, it will 
actually create the big object 3 times for my three test functions!
I though that the setUp() and tearDown() methods were here for exactly 
that purpose. If not, what are they here for ? :-)

It's my last post here about this, it's getting out of topic, I think.

--Pascal



--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message