JUnit test load .properties file when building with ant
807580Apr 25 2010 — edited Apr 26 2010Hello,
can anyone tell me how could I do unit tests with ant, so that unit test class files could load my .properties file.
My app works great in eclipse, tests and all, but when I am doing ant build, then it fails on unit tests, because it can not locate .properties file.
Myproject
---------+WEB-INF
------------------conf
----------------------+my.properties
------------------classes
------------------------+com.myproj.test.ConfTest.java
------------------------+com.myproj.Conf.Conf.java
------------------myfiles
------------------------+example.xml
Now when I run from eclipse I can get my.properties in Conf class easily.
Other classes get InputStreams to files from Conf class which is utility class.
When working with ant, then those paths don't work.
The only way I got my.properties file was to give path like:
String path = "../../../system.properties"
That means all files should come with "../../../example.xml"
But those paths won-t work in eclipse, only during ant building.
Please help me on this. How can I solve this?