• spring-mvc junit测试


    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());
        }
    }
  • 相关阅读:
    Vue源码解析
    开发调试的几个小技巧
    C#课后小作业
    C#随堂
    C#是数据类型
    插眼
    SQL基本的45题
    SQL创建数据库、建表、填入内容
    T-SQL语句基础
    SQL基本数据类型等
  • 原文地址:https://www.cnblogs.com/jecyhw/p/5490226.html
Copyright © 2020-2023  润新知