Return-Path: Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 66764 invoked by uid 500); 18 Jun 2003 09:57:57 -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 66751 invoked from network); 18 Jun 2003 09:57:57 -0000 Received: from cph3eusosrv3.cph.ops.eu.uu.net (146.188.104.167) by daedalus.apache.org with SMTP; 18 Jun 2003 09:57:57 -0000 Received: from limail.lint.lyngso-industri.dk (mail.lyngso-industri.dk [195.24.4.212]) by cph3eusosrv3.cph.ops.eu.uu.net (8.9.3p2/8.9.3) with ESMTP id JAA04466 for ; Wed, 18 Jun 2003 09:58:04 GMT Received: by limail.lint.lyngso-industri.dk with Internet Mail Service (5.5.2654.89) id ; Wed, 18 Jun 2003 11:58:08 +0200 Message-ID: <7858C99FF2E1C24BA3311BE8BEBE6A8EC1572B@limail.lint.lyngso-industri.dk> From: Flemming Haurum To: "'user@ant.apache.org'" Subject: JUnit and loading external test data from file Date: Wed, 18 Jun 2003 11:58:03 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2654.89) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C33580.1B8653E0" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ------_=_NextPart_001_01C33580.1B8653E0 Content-Type: text/plain; charset="iso-8859-1" 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 ------_=_NextPart_001_01C33580.1B8653E0--