maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Wood <aw...@redhat.com>
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

http://marc.theaimsgroup.com/?l=turbine-maven-user&m=108758456117192&w=2

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?
----------------
Regards,
Alex

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message