• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Maven test classpath

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Mikael Gyth
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic