Return-Path: Delivered-To: apmail-jakarta-ant-user-archive@apache.org Received: (qmail 40200 invoked from network); 3 Oct 2002 04:27:03 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 3 Oct 2002 04:27:03 -0000 Received: (qmail 19860 invoked by uid 97); 3 Oct 2002 04:27:46 -0000 Delivered-To: qmlist-jakarta-archive-ant-user@jakarta.apache.org Received: (qmail 19791 invoked by uid 97); 3 Oct 2002 04:27:45 -0000 Mailing-List: contact ant-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list ant-user@jakarta.apache.org Received: (qmail 19768 invoked by uid 98); 3 Oct 2002 04:27:45 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) content-class: urn:content-classes:message Subject: RE: JUnit: setUp() method called multiple times ? Date: Thu, 3 Oct 2002 12:27:06 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-ID: X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: JUnit: setUp() method called multiple times ? Thread-Index: AcJqlFmtn7QQyLQnRxaGR/C42G914gAAB9kQ From: "Dushyant Shrivastava" To: "Ant Users List" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, Yes this behaviour is correct! setUp() and tearDown() methods are = designed to be esecuted before and after each test in your test = case.What you could do is have just 1 setup method higher up in your = test case. You can do this by providing a wrapper class to override the = setUp method of TestSetup class and this enables the setUp of the = Wrapper class to be run just once before the tests.Acts like an = initialisation point. You can do the same for tearDown as well Something like this: class Wrapper extends TestSetup{ public Wrapper(junit.framework.Test p0){ super(p0); } public void setUp(){ oneTimeSetUp(); } public void tearDown(){ finalTearDown(); } } and then define your oneTimeSetUp method -> public static void oneTimeSetUp() { =20 } hope this helps!! Dushy -----Original Message----- From: P. Fleury [mailto:fleury@users.sourceforge.net] Sent: Thursday, October 03, 2002 12:17 PM To: Ant Users List Subject: JUnit: setUp() method called multiple times ? Hello, I have a single test class which has setUp() method. When I run it=20 through the junit task, in batch, the setUp method gets called once for=20 each test. Is that the normal behavior ? My problem is that multiple=20 runs of setUp make things fail... Anybody having similar issues? Ant 1.5, Sun's JDK 1.4.0_01, Linux=20 RH7.3, JUnit 3.7 --Pascal ###Here is the stub of my class (partially generated by NetBeans): public class JNIContentManagerTest extends TestCase { =20 public JNIContentManagerTest(java.lang.String testName) { super(testName); } =20 public static void main(java.lang.String[] args) { junit.textui.TestRunner.run(suite()); } =20 public static Test suite() { TestSuite suite =3D new TestSuite(JNIContentManagerTest.class); return suite; } =20 private MockContentManagerLink cml =3D null; private JNIContentManager jnicm =3D null; =20 private static int count_setups =3D 0; =20 protected void setUp() { count_setups++; System.err.println("setup #"+count_setups+" called."); // do initialization } =20 public void testMultipleContentManagerLink() { System.out.println("testMultipleContentManagerLink"); = =20 } =20 =20 /** Test of createNewReference method, of class=20 com.sony.vesta.jnicm.JNIContentManager. */ public void testCreateNewReference() { System.out.println("testCreateNewReference"); =20 } =20 /** Test of getFilename method, of class=20 com.sony.vesta.jnicm.JNIContentManager. */ public void testGetFilename() { System.out.println("testGetFilename"); } =20 } ### Ant the JUnit task: -- To unsubscribe, e-mail: = For additional commands, e-mail: = -- To unsubscribe, e-mail: For additional commands, e-mail: