我尝试运行spring框架的测试。我只使用xml上下文。在test(JUnit)类中,我指定了
mm n = new mm();
mm.MessageHandler messageHandler = n.new MessageHandler();
但我不知道如何在@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"springContext.xml"})
public class MyTest extends TestCase {
@Test
public void test() {
}
}
方法中访问spring上下文?我不能使用@Test
注释,因为我没有使用注释驱动的上下文
答案 0 :(得分:2)
测试类就像一个普通的bean。到目前为止,您可以在测试类中使用这两个: