On Thursday 02 August 2007 18:18:30 mbabauer wrote: > I need some assistance in how to add a folder to the classpath for JUnit > testing. > > My situation is this...we use Spring to wire most of our stuff together. I > would like to have some JUnits that use a test configuration for Spring. > The Spring config file(s) are located in <root>/src/test/resources, and the > test code itself is in <root>/src/test/java. I would like the JUnit to use > the ClasspathXmlApplicationContext, which looks to the classpath for a > given XML file for context configuration, but I have not found a way to add > the <root>/src/test/resources folder to the classpath for just the 'test' > phase. I am also not sure I am going down the right path.
are you running your junit test from maven like "mvn test" or do you run your junit test inside eclipse? If you run it with "mvn test" maven will copy the resources from src/test/resources to target/test-classes and it will have target/test-classes on the classpath if you run it inside eclipse check out the .classpath file or look at "Configure build path". My .classpath looks like this: <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/main/java"/> <classpathentry kind="src" output="target/test-classes" path="src/test/java"/> <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> <classpathentry excluding="**" kind="src" output="target/classes" path="src/test/resources"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> <classpathentry kind="output" path="target/classes"/> </classpath> your test should look something like this: import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; public class MyTests extends AbstractTransactionalDataSourceSpringContextTests { protected String[] getConfigLocations ( ) { return new String[] { "applicationContextTest.xml" }; } // .. tests } hope this helps in any way. if not give us some more information. kind regards Janning > For reference, I have attached my POM: > http://www.nabble.com/file/p11967682/pom.xml pom.xml --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]