Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Unit test fails to find file that's in source path, unless added to classpath
Unit test fails to find file that's in source path, unless added to classpath [message #886780] Fri, 15 June 2012 16:06 Go to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 355
Registered: July 2009
Senior Member
I have a unit test (integration test, really) which uses the Spring runner and needs to find my applicationContext.xml, which resides in src/main/webapp/WEB-INF. I have several tests that require this.

In my Maven POM, it works fine because I set the "additionalClasspathElements" to include this directory.

In Eclipse, I thought I could get this to work by simply adding "src/main/webapp/WEB-INF" as a source directory. It doesn't appear to be working. The only thing that's working is editing each run configuration for each test and adding that directory to the classpath. It's annoying that I have to do this for every test's run configuration.

Is there a better way to do this?
Re: Unit test fails to find file that's in source path, unless added to classpath [message #887364 is a reply to message #886780] Sat, 16 June 2012 13:33 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1036
Registered: July 2009
Senior Member
David M. Karr wrote on Fri, 15 June 2012 18:06
In Eclipse, I thought I could get this to work by simply adding "src/main/webapp/WEB-INF" as a source directory.


Why source folder? This would require that all your xml are correctly copied to some binary folder that's on the classpath, since source folders do not directly contribute to the classpath. In combinations of JDT and m2e unexpected things may happen regard such copying (check whether the source folder has any exlusion filters!).

Maybe adding the folder as a "Class Folder" works more straight-forward?

HTH,
Stephan

PS: for indepth advice regarding web applications the WTP forum will likely give better results.

Re: Unit test fails to find file that's in source path, unless added to classpath [message #887484 is a reply to message #887364] Sat, 16 June 2012 18:01 Go to previous message
David M. Karr is currently offline David M. KarrFriend
Messages: 355
Registered: July 2009
Senior Member
Stephan Herrmann wrote on Sat, 16 June 2012 09:33
David M. Karr wrote on Fri, 15 June 2012 18:06
In Eclipse, I thought I could get this to work by simply adding "src/main/webapp/WEB-INF" as a source directory.


Why source folder? This would require that all your xml are correctly copied to some binary folder that's on the classpath, since source folders do not directly contribute to the classpath. In combinations of JDT and m2e unexpected things may happen regard such copying (check whether the source folder has any exlusion filters!).

Maybe adding the folder as a "Class Folder" works more straight-forward?


Yes, that makes more sense, and I verified that that works.

Stephan Herrmann wrote on Sat, 16 June 2012 09:33

PS: for indepth advice regarding web applications the WTP forum will likely give better results.


I considered that, but this issue really has nothing to do with the fact that it's a web application.
Previous Topic:Console input encoding
Next Topic:Please I need Help Perspective Flex
Goto Forum:
  


Current Time: Fri Nov 28 06:05:12 GMT 2014

Powered by FUDForum. Page generated in 0.06188 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software