spring测试要引用junit及spring-test

    <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>

代码:

配置文件的引入:

单个文件:@ContextConfiguration(locations ="classpath:spring-mybatis.xml")

多个文件:@ContextConfiguration(locations ={"classpath:spring-mybatis.xml","classpath:application-context-provider.xml"})

import com.zoe.aop.dto.*;
import com.zoe.aop.service.out.DeptService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /**
* Created by gyoung on 2016/1/23.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations ={"classpath:spring-mybatis.xml","classpath:application-context-provider.xml"})
public class DeptServerTest { @Autowired
private DeptService deptService; @Test
public void deptSelectTest() {
DeptDto model= deptService.getOneById("2");
Assert.assertTrue(model.getId().equals("2"));
} @Test
public void updateTest(){
DeptDto model= new DeptDto();
model.setId("2");
model.setName("111");
deptService.update(model);
String id=model.getId();
} @Test
public void pageTest(){
QueryPage page=new QueryPage(1,5);
ServiceResultT<CorePageList> resultT= deptService.getList(page);
} @Test
public void deleteTtest(){
ServiceResult result= deptService.deleteById("1203");
} @Test
public void updateDbTest(){ }
}

Spring的测试的更多相关文章

  1. Spring TestContext测试框架搭建

    同样是测试,JUnit和Spring TestContext相比,Spring TestContext优势如下: 1.Spring TestContext可以手动设置测试事务回滚,不破坏数据现场 2. ...

  2. Spring引用测试

    上下文 using System; using Spring.Core; using Spring.Aop; using System; using Spring.Core; using Spring ...

  3. 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建三:配置spring并测试

    这一部分的主要目的是 配置spring-service.xml  也就是配置spring  并测试service层 是否配置成功 用IntelliJ IDEA 开发Spring+SpringMVC+M ...

  4. Spring MVC测试框架

    原文链接:http://jinnianshilongnian.iteye.com/blog/2004660 Spring MVC测试框架详解——服务端测试 博客分类: springmvc杂谈 spri ...

  5. Spring MVC测试框架详解——服务端测试

    随着RESTful Web Service的流行,测试对外的Service是否满足期望也变的必要的.从Spring 3.2开始Spring了Spring Web测试框架,如果版本低于3.2,请使用sp ...

  6. Spring Boot(七):spring boot测试介绍

    首先maven要引入spring-boot-starter-test这个包. 先看一段代码 @RunWith(SpringRunner.class) @SpringBootTest(webEnviro ...

  7. spring 学习(一):使用 intellijIDEA 创建 maven 工程进行 Spring ioc 测试

    spring学习(一):使用 intellijIDEA 创建 maven 工程进行 Spring ioc 测试 ioc 概念 控制反转(Inversion of Control,缩写为IOC),是面向 ...

  8. Spring Boot 测试时的日志级别

    1.概览 该教程中,我将向你展示:如何在测试时设置spring boot 日志级别.虽然我们可以在测试通过时忽略日志,但是如果需要诊断失败的测试,选择正确的日志级别是非常重要的. 2.日志级别的重要性 ...

  9. spring + junit 测试

    spring + junit 测试 需要一个工具类 package com.meizu.fastdfsweb; import org.junit.runner.RunWith; import org. ...

随机推荐

  1. JS/CSS缓存杀手——VS插件

    背景 前些天去考科目二,感觉经历了一场不是高考却胜似高考的考试(10年前的5分之差, 还是难以释怀)!    一行八人,就我学的时间最少(4天,8人一辆车),教练都觉得我肯定还得再来一次! 靠着运气和 ...

  2. jQuery之Ajax--底层接口

    1. $.ajax()方法:是jQuery最底层的Ajax实现.它的结构为:$.ajax(options).该方法只有一个参数,但在这个对象里面包含了$.ajax()方法所需要的请求设置以及回调函数等 ...

  3. Poisson泊松分布

    PMF 若随机变量\(K\)的概率质量函数PMF为 \[ P(K = k) = e^ {-\lambda} \frac {\lambda^k}{k!} \] 则称:\(K \sim Poisson(\ ...

  4. sublime3安装liveload,实现前端自动F5刷新html界面

    这两天倒腾编辑器,atom实在太大了,还是sublime好用 以前一直用sublime2, 然后更新到sublime3, 然后把一些必要的插件安装了一下:liveload(自动刷新): package ...

  5. JS获取URL地址参数

    <script> var url = "http://127.0.0.1/index.php?old_quantity=168&date=1478309879000$id ...

  6. JavaScript零基础学习系列三

    函数 函数:为了完成某个功能而定义的代码的集体.函数是数据类型,只读的对象:函数也是对象:代码的重用.(JavaScript中) 定义语法:function 函数名(形式参数1,形式参数2--){ / ...

  7. 软媒魔方 v6.2.1.0 绿色纯净版及经典版

    软媒魔方,最好用的 Windows 系统增强软件!从最早的优化大师发展为一款系统超级增强套装,自动化.智能化解决各种电脑问题.软媒魔方,全新一代Windows系统增强辅助工具,智能+专业双操控模式,系 ...

  8. Android相关学习资料整理

    小项目 2015-1-17 记事本 记事本 学习笔记: 结构清晰,简单易懂 2015-1-24 蘑菇街 仿蘑菇街 学习笔记:写博客的一种态度,讲解,配图,代码都很完善,值得学习 相机开发 学习笔记:思 ...

  9. TYVJ1338 QQ农场

    时间: 1000ms / 空间: 131072KiB / Java类名: Main 背景 Sandytea前段时间沉迷于QQ农场中……一天夜里,他梦见来到好友X的农场上…… 描述 这个农场和游戏中略有 ...

  10. 关于LuCi

    好吧,又长见识了...相见恨晚的赶脚,恩,居然是我喜欢的lua.其主页在这里:http://luci.subsignal.org/ The initial reason for this projec ...