开发者

Loading XML Files during Maven Test run

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

  1. 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?

  2. 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜