There is a simplier way : maven defines the "basedir" system property
I used it as my hudson continuous integration server doesn't set the project
root as current directory.
I also set default value to "." so that I can run the test under eclipse
File baseDir = new File( System.getProperty( "basedir", "." ) );
File f = new File( basdir, "src/test/resources/myImages";
2007/12/20, Kalle Korhonen <[EMAIL PROTECTED]>:
>
> To get the root of your test target dir, I'd simply do something like:
> String rootPath = "file://" +
> MyTestClass.class.getClassLoader().getResource("").getFile()
> + "../";
>
> Kalle
>
> On Dec 19, 2007 10:40 PM, Insitu <[EMAIL PROTECTED]> wrote:
>
> > HEllo,
> > "Heinrich Nirschl" <[EMAIL PROTECTED]> writes:
> > >
> > > I seem to miss something, why does
> > >
> > > new File("test/resources/myImages")
> > >
> > > not work?
> >
> >
> > Because you can never be sure that the current directory is the root
> > directory of your project.
> > You can define environment variables in the surefire plugin
> > (<sysProperties>), so you could say something like:
> >
> > <sysProperties>
> > <property>
> > <name>test.resources.dir</name>
> > <value>${build.testOutputDirectory}</value>
> >
> > HTH,
> > --
> > Arnaud Bailly, PhD
> > OQube - Software Engineering
> > http://www.oqube.com
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>