Question regarding spring and unit tests

Ok so I have a base test class which I am extending and creating unit tests from. This is all JUnit. So we are loading up our config files like so in the abstract class:

private static final String [] APPLICATION_CONTEXTS = new String[] { "src/test/resources/some-config1.xml",
            "src/main/package/config/another-config.xml", "src/test/resources/yetanother-config.xml" };

So now when I run a test case that is inheriting from the above parent class in Intellij, it complains saying:

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [C:\path\to\project\src\test\resources\some-config1.xml]; nested exception is java.io.FileNotFoundException: src\test\resources\some-config1.xml (The system cannot find the path specified)

Yet when I run it in Eclipse, there is no problem none whatsoever. Its as if eclipse is smart enough to figure out that the first config file is in the same module of the project, the other one is from another project module, and so on.

All I am doing is loading up our code into the IDEs using the pom.xml. Any ideas? I really hate having to have Eclipse and Intellij open and having to switch back and forth between the two. Any suggestions would be very much appreciated. Hope my post makes some sense.

Cheers!

0

You should set proper working directory in your test run configuration.


0

请先登录再写评论。