利用Spring的junit4测试

时间:2019-01-02 22:55:50   收藏:0   阅读:192

利用Spring的JUnit4进行测试
不需要再显式创建Spring容器和getBean

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class MyTest {
    @Autowired//byType
    private School school;
    @Autowired
    private Student student;

    @Test
    public void test01() {
        System.out.println(school);
        System.out.println(student);
    }

}

原文:https://www.cnblogs.com/darknessplus/p/10211708.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!