测试弹簧配置文件

时间:2015-08-14 08:31:17

标签: spring maven testing

我有一个Spring配置文件,其中定义了一些bean,现在我想在我的unite / integration测试中使用这些bean。有没有办法在没有主资源和测试资源的文件副本的情况下做到这一点?

1 个答案:

答案 0 :(得分:0)

您的测试类必须如下所示:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:path/to/your/context.xml" })
public class MyTest {
  @Autowired
  private MyBean beanUnderTest;
}