zoukankan      html  css  js  c++  java
  • 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());
        }
    }
  • 相关阅读:
    HTML5 表单自学记录
    HTML5表单
    HTML不常用的表单属性-fieldset
    HTML5-Y音频与视频
    解决HTML5标签兼容的办法搜集
    HTML5标签的兼容处理
    HTML5-语义化标签
    JS自学大全
    HTML5增强的表单
    照片格式的区别
  • 原文地址:https://www.cnblogs.com/jecyhw/p/5490226.html
Copyright © 2011-2022 走看看