I have a very basic question on usage of resource files (like XML etc.) for Junit tests in a Maven build environment. There were few related questions to this topic here but it answered my question only partly. I am hoping someone can give a comprehensive answer for this issue
I need clarification on
If I keep my resource files under 开发者_StackOverflow中文版src/test/resources/, to load this file in my unit test during maven build, what is file system path I should provide?
The same unit tests are also run at an individual level by developers in their own environments i.e. Without using maven test goal and directly using a run config in Eclipse.
What is the best way to support both these run scenario and keeping the files in a single location?
You should use Class.getResourceAsStream() so that you are not depend upon the file paths.
Read this turorial: Accessing Resources
精彩评论