• 基于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);
      }


    }

  • 相关阅读:
    解决ssh或ftp下root用户认证失败问题
    setsockopt IP_ADD_MEMBERSHIP error!No such device的解决方案
    嵌入式Linux软件工程师面试题一
    00.嵌入式Linux开发环境搭建
    这个是豆瓣查书的api
    CentOS7.x安装MongoDB3.2.3教程
    Linux(Centos7)yum安装最新mysql
    解决npm速度慢的问题!!!
    windows下Gulp入门详细教程
    hibernate中hql查询
  • 原文地址:https://www.cnblogs.com/yipihema/p/4921220.html
Copyright © 2020-2023  润新知