需要引用的依赖:

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);
  }

}

基于spring 的单元测试的更多相关文章

  1. 基于spring与mockito单元测试Mock对象注入

    转载:http://www.blogjava.net/qileilove/archive/2014/03/07/410713.html 1.关键词 单元测试.spring.mockito 2.概述 单 ...

  2. step6----->往工程中添加spring boot项目------->修改pom.xml使得我的project是基于spring boot的,而非直接基于spring framework

    文章内容概述: spring项目组其实有多个projects,如spring IO platform用于管理external dependencies的版本,通过定义BOM(bill of mater ...

  3. Spring实战5:基于Spring构建Web应用

    主要内容 将web请求映射到Spring控制器 绑定form参数 验证表单提交的参数 对于很多Java程序员来说,他们的主要工作就是开发Web应用,如果你也在做这样的工作,那么你一定会了解到构建这类系 ...

  4. 基于Spring设计并实现RESTful Web Services(转)

    基于Spring设计并实现RESTful Web Services 在本教程中,你将会使用Spring来创建一个具有生产力的RESTful网络服务. 为什么用RESTful网络服务? 从和Amazon ...

  5. Spring Boot 单元测试示例

    Spring 框架提供了一个专门的测试模块(spring-test),用于应用程序的单元测试. 在 Spring Boot 中,你可以通过spring-boot-starter-test启动器快速开启 ...

  6. 基于Spring Boot/Spring Session/Redis的分布式Session共享解决方案

    分布式Web网站一般都会碰到集群session共享问题,之前也做过一些Spring3的项目,当时解决这个问题做过两种方案,一是利用nginx,session交给nginx控制,但是这个需要额外工作较多 ...

  7. 基于Spring的可扩展Schema进行开发自定义配置标签支持

    一.背景 最近和朋友一起想开发一个类似alibaba dubbo的功能的工具,其中就用到了基于Spring的可扩展Schema进行开发自定义配置标签支持,通过上网查资料自己写了一个demo.今天在这里 ...

  8. 基于Spring MVC的Web应用开发(三) - Resources

    基于Spring MVC的Web应用开发(3) - Resources 上一篇介绍了在基于Spring MVC的Web项目中加入日志,本文介绍Spring MVC如何处理资源文件. 注意到本项目的we ...

  9. RESTLET开发实例(三)基于spring的REST服务

    http://www.lifeba.org/arch/restlet_spring_3.html 前面两篇文章,我们介绍了基于JAX-RS的REST服务以及Application的Rest服务.这里将 ...

随机推荐

  1. linux 批量kill进程

    ps -ef | grep module- | grep -v module-mxm | cut -c 9-15 | xargs kill -9 ps -ef | grep module- 查找关键字 ...

  2. jquery图片轮播

    <html> <head> <title>position</title> <style type="text/css"> ...

  3. CKEditor 配置

    在asp.net 中注意需要特殊处理控件的ID 先引入js <script type="text/javascript" src="ckeditor/ckedito ...

  4. iOS 运行时

    1.点击每一个cell都要跳转到一个控制器,swich会很麻烦,那么可以用运行时来进行跳转. a. 定义一个数组用来存放控制器的名字 - (NSArray *)controllerArr{ if (_ ...

  5. 【转载】Linux常用命令列表

    原文地址:http://www.cnblogs.com/Javame/p/3968343.html 1 目录与文件操作 1.1 ls(初级) 使用权限:所有人 功能 : 显示指定工作目录下之内容(列出 ...

  6. mysql常见错误及解决方案

    mysql error 2005 - Unknown MySQL server host 'localhost'(0) 此错误一般为地址信息错误,注意是否有空格. 在连接本地数据库时,最好使用127. ...

  7. LeetCode——Balanced Binary Tree(判断是否平衡二叉树)

    问题: Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced bin ...

  8. 浅谈SQLiteOpenHelper之onCreate例子

    哈喽大家好!如果你感觉SQLiteOpenHelper不懂的可以看一下.  onCreate(SQLiteDatabase db) : 当数据库被首次创建时执行该方法,一般将创建表等初始化操作在该方法 ...

  9. BestCoder 2nd Anniversary

    A题 Oracle http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=703&pid=1001 大数相加: ...

  10. Activiti工作流学习(三)Activiti工作流与spring集成

    一.前言 前面Activiti工作流的学习,说明了Activiti的基本应用,在我们开发中可以根据实际的业务参考Activiti的API去更好的理解以及巩固.我们实际的开发中我们基本上都使用sprin ...