I had the same problem and the solution was to access files via Class.getResourceAsStream(), doing so you don't have any problem with the current directory that is the problem here, but you only care about the Classpath that obviously is set up perfectly.
To make this approach working you should also add a resource tag inside the test definition in project.xml so all the data files are included in the classpath when a test is launched Hope this helps Max -----Original Message----- From: Trygve Laugst�l [mailto:[EMAIL PROTECTED] Sent: Saturday, July 10, 2004 3:28 PM To: Maven Users List Subject: Re: Reactor: tests failing (working dir set to master proj dir not child proj dir) On Fri, Jul 09, 2004 at 11:38:58PM -0400, Omair-Inam Abdul-Matin wrote: > I'm using JUnit to run some regression tests that need to read in > configuration and data files. For this it is necessary that the working > directory be the same as the project directory. Recently the project > was subdivided into a master project and child subprojects. Now when I > try to run unit tests by invoking the master build target, the tests > fail because apparently the working directory is the directory of the > master project not the current child project. I believe this topic has > been brought up in a previous post but I was not able to find the > solution to the problem. Try to read the System.getProperty( "basedir" ) should yield the basedir for your project when you run your testcase from maven. But this is not the case when you are running the testcase from eclipse so I'd recomend that you make a super test case and have a method called getBasedir() like this: protected String getBasedir() { return System.getProperty( "basedir", new File( "" ).getAbsolutePath() ); } -- Trygve > > Can someone please nudge me in the correction direction? > > Omair --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
