aspose file tools*
The moose likes JSF and the fly likes Maven test classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Maven test classpath" Watch "Maven test classpath" New topic
Author

Maven test classpath

Mikael Gyth
Greenhorn

Joined: Sep 30, 2012
Posts: 7
Hi.

I get an error when i try to run my unittest, because they can't find my resource files.
They are located at:
src/main/resources/Bundle.properties
As I understand it from this post I need to add this path to my test classpath so that it's avaliable to the tests too.
But I can't figure out what file, menu or property i need to edit to set it.
I am using Netbeans 7.2 and Maven for a JSF project.

Can anyone give me som decent instructions on how to add this path to the test classpath in this environment.

Br.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

Resources used only by testing should go in src/test/resources, not src/main/resources.

Maven will automatically copy the resources when it runs the tests. You do not have to specify anything.


Customer surveys are for companies who didn't pay proper attention to begin with.
Mikael Gyth
Greenhorn

Joined: Sep 30, 2012
Posts: 7
Thanks for reply.

I don't have any resources used only by testing, only my regular resources that are located in src/main/resources.

I guess I must have something configured wrong in that case, because my test methods can't find the resources.
Do I have to manually create the src/test/resources for maven to copy the files there when the tests run?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

Maven copies to the "target" directory when building and when testing. Nowhere else. A "mvn clean" destroys that directory and all its subdirectories".

There are exceptions to src/xxxx/resources if you are building something other than a basic jar. In particular, a WAR build pulls its resources from src/main/webapp, and copies them into the resulting webapp relative to its root (not its /WEB-INF/classes).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Maven test classpath