This may not be the only or best solution, but here is how I've solved this problem.
Two examples.
Example 1. I have test resources in the source hierarchy under src/test, and my test
classes look for resources in the appropriate package hierarchy.
In project.xml:
<testResources>
<testResource>
<directory>src/test</directory>
<includes>
<include>**/*.properties</include>
</includes>
</testResource>
</testResources>
In this example, the test goal will copy all the test resources from the src/test
hierarchy into the corresponding directories under test-classes.
Example 2. I have test resources in a single level directory called src/work, and my
test classes look for files in the default working directory.
In project.xml:
<testResources>
<testResource>
<directory>src/work</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.jocl</include>
<include>**/*.xml</include>
</includes>
</testResource>
</testResources>
In this case, you'll also need to add the following properties to project.properties:
# run tests in separate VM
maven.junit.fork=yes
maven.junit.dir=${basedir}/target/test-classes
In this example, the test goal will copy the specified resources to the test-classes
directory, and the VM will use the specified directory as the default working
directory when the test is run.
HTH
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 25, 2002 7:34 AM
> To: [EMAIL PROTECTED]
> Subject: RE: How do I include a text file in my test resource..
>
>
> What about if I want to put my TestFileHolderFile.txt under my test code
> hierarchy? I only need the text file for testing, so I don't want to
> clutter up my production code?
>
> This is what I am currently working with, to no avail.
>
>
> <build>
> <nagEmailAddress></nagEmailAddress>
> <sourceDirectory>src</sourceDirectory>
> <unitTestSourceDirectory>tests/test</unitTestSourceDirectory>
> <aspectSourceDirectory></aspectSourceDirectory>
>
> <sourceModifications>
> <sourceModification>
> <excludes>
> <exclude>com/**/*.*</exclude>
> </excludes>
> </sourceModification>
> </sourceModifications>
>
>
> <unitTest>
> <includes>
> <include>**/*Test.java</include>
> <include>**/Test*.java</include>
>
> </includes>
> <resources>
> <includes>
> <include>**/*.txt</include>
> </includes>
> </resources>
> </unitTest>
>
> <resources>
> <includes>
> <include>**/*.txt</include>
> </includes>
> </resources>
> <jars></jars>
> </build>
>
> Thanks,
> Eric Pugh
>
> -----Original Message-----
> From: WANGHB [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, November 23, 2002 8:32 AM
> To: Turbine Maven Users List
> Subject: RE: How do I include a text file in my test resource..
>
>
> Hi Eric:
> If u want to copy the source file into the class path,
> u must set the sourceDirectory and resources and jarResources under the
> build element.
> like this
>
> <build>
> <sourceDirectory>#fill here with ur resource root dir#</sourceDirectory>
> ..........
> <resources>
> <includes>
> <include>**/*.txt</include>
> </includes>
> </resources>
> <jarResources>
> <jarResource>**/*.txt</jarResource>
> </jarResources>
> </build>
> If TestFileHolderFile.txt under the root resource dir,
> ur code will work!
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 2002-11-23 (星期六) 1:11
> To: [EMAIL PROTECTED]
> Cc:
> Subject: How do I include a text file in my test resource..
>
>
>
> In my Junit test, I have this line:
>
> File testFile = new
> File(FileHolder.class.getResource("TestFileHolderFile.txt").toString());
>
> }
>
> However, the TestfileHolderFile.txt never gets copied over into either my
> target/test-classes or my target/classes dir.. How can I get it copied
> over? I used to do this in project.xml:
>
> <unitTest>
> <includes>
> <include>**/*Test.java</include>
> <include>**/Test*.java</include>
>
> </includes>
> <resources>
> <includes>
> <include>**/*.txt</include>
> </includes>
> </resources>
> </unitTest>
>
> However, as of last nights CVS Head, this no longer works.. I
> looked at the
> plugin, and I think I am doing everything properly, but no joy...
>
> Thanks,
> Eric
>
>
>
> IMCaptor
>
> Best Regards
>
>
>
>
>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>