zoukankan      html  css  js  c++  java
  • 基于spring 的单元测试

    需要引用的依赖:

    import org.junit.runner.RunWith;
    import org.springframework.test.context.ContextConfiguration;
    import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

    maven依赖为:

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>3.2.3.RELEASE</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.11</version>
                <scope>test</scope>
            </dependency>

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration({ "classpath:applicationContext-springService.xml" })
    public class DistributeServiceTest {


    @Resource
    DistributeService distributeService;

      @Test
      public void testGetStatisticsByChannel() {
        long beginTime = 0;
        long endTime = 1545615321794L;
        List<Distribute> distributeInfo = new ArrayList<>(3);
        Distribute distribute = new Distribute();
        distribute.setChannelNo("1055100004");
        distributeInfo.add(distribute);
        distributeService.getStatisticsByChannel(distributeInfo, beginTime, endTime);

        Assert.assertTrue(distributeInfo.get(0).getAndroidTotal().equals("3"));
      }

        

      @Test
      public void test() {
        System.out.println(123);
      }


    }

  • 相关阅读:
    c语言中while((c=getchar())!=EOF)怎样才能输入EOF是循环中断
    Python学习笔记之装饰器原理
    Ubuntu中使用pip3报错
    Django配置xadmin后台模板之坑(一)
    ES6之字符串扩展
    Koa中设置中文Cookie值
    node中中间件body-parser的实现方式
    CSS笔记之Grid网格系统
    从0开始搭建vue+webpack脚手架(四)
    从0开始搭建vue+webpack脚手架(三)
  • 原文地址:https://www.cnblogs.com/yipihema/p/4921220.html
Copyright © 2011-2022 走看看