java - Resolving relative path when running ClasspathSuite -
when run junit tests using classpathsuite , 1 of unit tests wants load file using relative path, use base path of classpathsuite instead of base path of unit test.
so example if unit test tries load file this:
file file = new file("src/test/resources/test.xml");
it try load file relative location of classpathsuite , not relative location of unit test.
is there way change this?
i assume using eclipse. use myclass.class.getclassloader().getresourceasstream(<filename>)
. in resources getclassloader()
able location of file easily, if using eclipse. code be,
file file = new file(myclass.class.getclassloader().getresourceasstream("test.xml"));
Comments
Post a Comment