I'm not necessarily understanding exactly where you have these pathnames (in
your actual TestCase extending classes?).

But, two ideas come to mind:

- use test files from the class path, and use Class.getResource to get files
(I copy all non-.java files from my source directory to my test cases build
directory during the build to get them there)

- use a system property to set an absolute path to your test cases using the
<sysproperty> nested element of <junit>.

I employ both of these techniques successfully.

    Erik



----- Original Message -----
From: "Viraj Purang" <[EMAIL PROTECTED]>
To: "Ant Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, May 28, 2002 4:40 PM
Subject: problem running Junit tests : "current working directory"


Hi,
    A few developers I have been working with have a habit of using "not
fully qualified" pathnames for directories and files in Junit test cases.
Consequently I have been getting "files not founds" in case I call my Junit
build.xml file from other files in higher level directories, as it searches
the included xml file relative to wherever the classfile is running from.

If I drill down the directory where these test cases are , it seems to pick
up the relative path fine and it works manually.

Can anyone think of a possible way of setting the current working directory
to a lower level  directory or any other  way of resolving this problem.

Regards,
Viraj Purang

Error Logs
----------------------------------------------------------------------------
----

    [junit] Tests run: 5, Failures: 0, Errors: 1, Time elapsed: 90.851 sec

    [junit] Testcase: M0_PurchaseOrder took 1.643 sec
    [junit]     Caused an ERROR
    [junit] test-files\M0_PurchaseOrder.in.xml (The system cannot find the
path
specified)
    [junit] java.io.FileNotFoundException:
test-files\M0_PurchaseOrder.in.xml (T
he system cannot find the path specified)
    [junit]     at java.io.FileInputStream.open(Native Method)
    [junit]     at java.io.FileInputStream.<init>(FileInputStream.java:59)
    [junit]     at java.io.FileInputStream.<init>(FileInputStream.java:90)



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to