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. 一行python代码实现树结构

    树结构是一种抽象数据类型,在计算机科学领域有着非常广泛的应用.一颗树可以简单的表示为根, 左子树, 右子树. 而左子树和右子树又可以有自己的子树.这似乎是一种比较复杂的数据结构,那么真的能像我们在标题 ...

  2. 线段树 HDU 3397

    5种操作 具体看代码 #include<iostream> #include<stdio.h> #include<string.h> #include<alg ...

  3. MySQL远程连接丢失问题解决方法Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0

    最近远程连接mysql总是提示 Lost connection 很明显这是连接初始化阶段就丢失了连接的错误 其实问题很简单,都是MySQL的配置文件默认没有为远程连接配置好,只需要更改下MySQL的配 ...

  4. 跳转到某个Activity

    跳转 Activity之间的跳转 可以依靠Intent 简单粗暴的办法是 Intent intent= new Intent(*.this, MainActivity.class); startAct ...

  5. Nginx简易配置文件(三)(文件缓存)

    server { listen 80; listen 443 ssl; server_name user.17.net userapi.17.net; access_log logs/user/acc ...

  6. 5 构建Mysql+heartbeat+DRBD+LVS集群应用系统系列之生产环境下drbd裂脑处理

    preface 公司的业务变更,导致服务器要搬迁,所以需要关闭服务器,然后到新地在开启服务器. 关机前确定drbd+heartbeat+mysql是正常使用的,没有异常,Heartbeat和drbd都 ...

  7. Protocol Framework - SNMP Tutorial

    30.4 Protocol Framework TCP/IP network management protocols2 divide the management problem into two ...

  8. JointBoost+CRF+GraphCut做手绘草图的分割

    研究生做的稍微有点水平的就这两个项目了:一个是利用SVM做手绘草图的分类,另一个是利用JointBoost+CRF做手绘草图的分割.总结得出的经验是做研究的方法就是将别人大神的代码看懂然后改成适合自己 ...

  9. AFNetworking certificate AFNetworking 证书设置

    + (AFSecurityPolicy*)customSecurityPolicy { // /先导入证书 NSString *cerPath = [[NSBundle mainBundle] pat ...

  10. 1JavaEE应用简介----青软S2SH(笔记)

    这本书主要是讲解Struts2,spring,Hibernate框架的, 因为工作中用的较多的是SpringMVC,Struts2用的较少,所以想系统学习一下,就买了这本书. 这本书是青软的,虽然是培 ...