Return-Path: Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 79969 invoked by uid 500); 18 Jun 2003 13:42:47 -0000 Mailing-List: contact user-help@ant.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 user@ant.apache.org Received: (qmail 79958 invoked from network); 18 Jun 2003 13:42:47 -0000 Received: from gatekeeper.e-markets.com (HELO ames.e-markets.com) (65.161.81.2) by daedalus.apache.org with SMTP; 18 Jun 2003 13:42:47 -0000 Received: from localhost (localhost [127.0.0.1]) by ames.e-markets.com (Postfix) with ESMTP id 708482A2008 for ; Wed, 18 Jun 2003 08:42:48 -0500 (CDT) Received: from ames.e-markets.com ([127.0.0.1]) by localhost (marge.e-markets.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 04083-01-5 for ; Wed, 18 Jun 2003 08:42:46 -0500 (CDT) Received: from Eidon (tosca.e-markets.com [192.168.8.68]) by ames.e-markets.com (Postfix) with SMTP id 714D72A2005 for ; Wed, 18 Jun 2003 08:42:46 -0500 (CDT) From: "Nicolas Johnson" To: "Ant Users List" Subject: RE: JUnit and loading external test data from file Date: Wed, 18 Jun 2003 08:48:38 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal In-Reply-To: <7858C99FF2E1C24BA3311BE8BEBE6A8EC1572B@limail.lint.lyngso-industri.dk> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Virus-Scanned: E-Markets X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N You might try an alternative solution. When I use external files in my Test classes I get the file name from a property. I set the property in a forked jvm instance that is used when running JUnit. Something like: ... that way I can easily change the path to the test files without having to recompile the sourcecode. -----Original Message----- From: Flemming Haurum [mailto:fha@lyngsoesystems.com] Sent: Wednesday, June 18, 2003 4:58 AM To: 'user@ant.apache.org' Subject: JUnit and loading external test data from file I have a problem with Junit test code that needs to load external test data from files. My test code opens the test data file the following way: try { FileReader fileReader = new FileReader("testdatafile.txt"); bufferedReader = new BufferedReader(fileReader); . . . } catch (FileNotFoundException e) { assertTrue("Run the unit test from within the test directory!!!!" + e.getMessage(), false); } catch (IOException e) { assertTrue(e.getMessage(), false); } It works when I am running the Junit from the directory where the test code and the test files are located. ant -find build.xml junit But when I run the Junit from a higher level in the directory structure it fails as the test data file is specified by name without path. I would hate if I have to use absolute file reference as "/usr/fha/project/test/com/flemming/util/testdatafile.txt". My build.xml contains the following regarding the junit. Should I use the 'dir' attribute to specify that the VM should be invoked in a different directoy? And in that case how to write the statement as I am using the batchtest+fileset to find directories containing the Junit test code. Do some of you have experience or advise on how to load the test data files. Regards Flemming --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org