You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jared Blitzstein <te...@blitzstein.net> on 2008/04/15 18:21:57 UTC
How can I add a directory to the classpath to run JUnit tests in the command line?
I'm doing a demo app using JUnit 4 and Spring annotations and having
some trouble getting maven to run my tests. They launch and run
correctly in eclipse, but mvn test cannot find my xml context files
because they're not on the classpath (they're in /webapp/WEB-INF/) and
my JUnit test is using @ContextConfiguration(locations = { "/todo-
application-context.xml", "/todo-data.xml" }). I saw
maven.plugin.classpath and maven.test.classpath (though it seems maven
1.x) and launching via "mvn test -Dmaven.plugin.classpath=/src/main/
webapp/WEB-INF/" (i've tried the absolute path too) but it's still
giving me a FileNotFound exception on my *.xml files. Any ideas?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How can I add a directory to the classpath to run JUnit tests in the command line?
Posted by Jared Blitzstein <te...@blitzstein.net>.
Answered my own question I think, I did it via the POM
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>src/main/webapp/WEB-INF/</
additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
However, my tests don't seem to be returning. I can see it execute the
first one, then just sit there.
On Apr 15, 2008, at 12:21 PM, Jared Blitzstein wrote:
> I'm doing a demo app using JUnit 4 and Spring annotations and having
> some trouble getting maven to run my tests. They launch and run
> correctly in eclipse, but mvn test cannot find my xml context files
> because they're not on the classpath (they're in /webapp/WEB-INF/)
> and my JUnit test is using @ContextConfiguration(locations = { "/
> todo-application-context.xml", "/todo-data.xml" }). I saw
> maven.plugin.classpath and maven.test.classpath (though it seems
> maven 1.x) and launching via "mvn test -Dmaven.plugin.classpath=/src/
> main/webapp/WEB-INF/" (i've tried the absolute path too) but it's
> still giving me a FileNotFound exception on my *.xml files. Any ideas?