Jason van Zyl wrote:
On Sat, 2004-07-10 at 13:08, Omair-Inam Abdul-Matin wrote:
I've tried the following and my unit tests still fail because the
working directory seems to be the directory of the master project.
There is no way to reliably set the working directory in Java. To make
your tests reactor-able you must reference resources using the "basedir"
system property that is made available in tests by the junit plugin.
So the general pattern is:
public class MyTest extends TestCase
{
private String basedir;
protected void setUp()
{
basedir = System.getProperty( "basedir" );
}
public void testThatUsesAResourceFromTheFileSystem()
{
File resource = new File( basedir, "src/test/resources/MyTestResource.txt" );
// do you stuff with the file system resource.
}
}
Thanks... that's exactly what I was looking for.. I didn't know how to
fetch maven-defined properties in a java file.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]