【发布时间】:2012-12-03 16:21:44
【问题描述】:
我有一个弹簧单元测试,它扩展了位于其他项目中的其他测试(tests-common)。 我的上下文文件 (my-context.xml) 与 MyTest 位于同一个包中。 基本上下文文件(“base-context.xml”)与 BaseTest 位于同一包中。 文件看起来像:
@ContextConfiguration(locations = { "my-context.xml"})
public class MyTest extends BaseTest {
@ContextConfiguration(locations = { "base-context.xml" })
public abstract class BaseTest extends AbstractJUnit4SpringContextTests{
问题是:BaseTest 找到“base-context.xml”,但 MyTest 找到“my-context.xml”的 FileNotFoundException。
如果我将 BaseTest 和 my-context.xml 文件移动到与 BaseTest 相同的包中 - 一切正常。
可能是什么问题?
【问题讨论】:
-
您可以尝试在文件名前加上
classpath:前缀吗?
标签: spring unit-testing junit