首页 > 编程语言 > 详细

spring-mvc junit测试

时间:2016-05-13 18:59:32      阅读:119      评论:0      收藏:0      [点我收藏+]
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * Created by jecyhw on 16-5-12.
 */
@RunWith(SpringJUnit4ClassRunner.class)//使用Spring整合Junit的测试类测试
@ContextConfiguration(locations = {//spring-mvc配置文件
        "file:src/main/resources/applicationContext.xml"
})
@TestPropertySource(locations = {//所用到的properties文件
        "file:src/main/resources/mongodb.properties",
        "file:src/main/resources/weixin.properties"
})
abstract public class BaseTest extends AbstractJUnit4SpringContextTests {
    //其他所有test继承BaseTest即可
}
//简单的测试类
public class EventDaoTest extends BaseTest{

    @Resource
    EventDao eventDao;

    @Test
    public void list() {
        JsonUtil.writeAsString(eventDao.list());
    }
}

 

spring-mvc junit测试

原文:http://www.cnblogs.com/jecyhw/p/5490226.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!