You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Maczka Michal <mi...@imtf.ch> on 2004/07/12 10:38:56 UTC
RE: Reactor: tests failing (working dir set to master proj dir no
t child proj dir)
> -----Original Message-----
> From: Omair-Inam Abdul-Matin [mailto:oiinamul@cs.uwaterloo.ca]
> Sent: Saturday, July 10, 2004 5:39 AM
> To: users@maven.apache.org
> Subject: Reactor: tests failing (working dir set to master
> proj dir not
> child proj dir)
>
>
> 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.
>
> Can someone please nudge me in the correction direction?
>
> Omair
>
>
You may also conider using classloader for loading your configuration files:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ClassLoader.html#findResou
rce(java.lang.String)
Once you have an URL of required resource you can easly convert it to a File
object and then use methods like file.getParentFile()
for traversing directories
Using this technique you can more easly test your code in your IDE.
Michal
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Reactor: tests failing (working dir set to master proj dir no
t child proj dir)
Posted by Ben Walding <be...@walding.com>.
Maczka Michal wrote:
>
>
>>-----Original Message-----
>>From: Omair-Inam Abdul-Matin [mailto:oiinamul@cs.uwaterloo.ca]
>>Sent: Saturday, July 10, 2004 5:39 AM
>>To: users@maven.apache.org
>>Subject: Reactor: tests failing (working dir set to master
>>proj dir not
>>child proj dir)
>>
>>
>>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.
>>
>>Can someone please nudge me in the correction direction?
>>
>>Omair
>>
>>
>>
>>
>
>You may also conider using classloader for loading your configuration files:
>
>
>
Another option is to check the basedir property ->
System.getProperty("basedir") which is the base of the current project.
I personally prefer the classloader approach, but it's worth knowing
about both methods.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org