maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Wood <>
Subject RE: [m1] Reading Test Resources
Date Fri, 23 Sep 2005 20:50:44 GMT
> Do you mean the resource files aren't getting put into
> target/test-classes or that target/test-classes isn't in the classpath? 
> If the resource file is in a subdirectory of src/test/resources, then
> your filename in the test code will need to include the subdirectory
> name.
> ..David..

Thanks David, the subdirectory path was the trick.  I had the files in 
target/test-classes/resources/XML and the two lines below worked.

String filename = "/resources/XML/valid.xml";
InputStream is = MyClassTest.class.getResourceAsStream(filename);

Just as a side-note, the slash before "resources" is required.

I found a thread discussing the same issue here

Is there anyway to add the resource directories to the classpath as well 
so I don't have to use as long of a path when I load up the files?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message