Spring的测试
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的测试的更多相关文章
- Spring TestContext测试框架搭建
同样是测试,JUnit和Spring TestContext相比,Spring TestContext优势如下: 1.Spring TestContext可以手动设置测试事务回滚,不破坏数据现场 2. ...
- Spring引用测试
上下文 using System; using Spring.Core; using Spring.Aop; using System; using Spring.Core; using Spring ...
- 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建三:配置spring并测试
这一部分的主要目的是 配置spring-service.xml 也就是配置spring 并测试service层 是否配置成功 用IntelliJ IDEA 开发Spring+SpringMVC+M ...
- Spring MVC测试框架
原文链接:http://jinnianshilongnian.iteye.com/blog/2004660 Spring MVC测试框架详解——服务端测试 博客分类: springmvc杂谈 spri ...
- Spring MVC测试框架详解——服务端测试
随着RESTful Web Service的流行,测试对外的Service是否满足期望也变的必要的.从Spring 3.2开始Spring了Spring Web测试框架,如果版本低于3.2,请使用sp ...
- Spring Boot(七):spring boot测试介绍
首先maven要引入spring-boot-starter-test这个包. 先看一段代码 @RunWith(SpringRunner.class) @SpringBootTest(webEnviro ...
- spring 学习(一):使用 intellijIDEA 创建 maven 工程进行 Spring ioc 测试
spring学习(一):使用 intellijIDEA 创建 maven 工程进行 Spring ioc 测试 ioc 概念 控制反转(Inversion of Control,缩写为IOC),是面向 ...
- Spring Boot 测试时的日志级别
1.概览 该教程中,我将向你展示:如何在测试时设置spring boot 日志级别.虽然我们可以在测试通过时忽略日志,但是如果需要诊断失败的测试,选择正确的日志级别是非常重要的. 2.日志级别的重要性 ...
- spring + junit 测试
spring + junit 测试 需要一个工具类 package com.meizu.fastdfsweb; import org.junit.runner.RunWith; import org. ...
随机推荐
- LeetCode:Count and Say
题目链接 The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 11 ...
- [CareerCup] 2.5 Add Two Numbers 两个数字相加
2.5 You have two numbers represented by a linked list, where each node contains a single digit. The ...
- SharePoint远程调试CSS
1.在浏览器中找到需要调试的样式文件: 2.在SharePoint打开对应的文件,直接修改看到效果:
- 自创yum源
这里我们用U盘装完系统以后,我们要是使用yum命令的话,我们是装不上包的 这个时候我们装系统的时候 [root@kz-002 Packages]# df -h Filesystem Size Used ...
- centos7 安装jdk1.8
安装之前下熟悉以下连个文件 (1)/etc/profile 全局(公有)配置,不管是哪个用户,登录时都会读取该文件. (2)~/.bashrc: 该文件包含专用于你的bash shell的bas ...
- 7.Android开源项目WheelView的时间和地址联动选择对话框
类似WheelView的时间和地址联动选择对话框在现在App经常看到,今天小结下. 主布局界面: <LinearLayout xmlns:android="http://schemas ...
- 认识和使用NSOperation
原文链接:http://www.jianshu.com/p/2de9c776f226 NSOperation是OC中多线程技术的一种,是对GCD的OC包装.它包含队列(NSOperationQueue ...
- 团队博客作业- Week3
成员介绍 韩青长 测试 我是韩青长,技术小白,抱着对软工的好奇和对未来工作的憧憬选了这门课.暂时选择了测试的工作,也对开发和UI有一定兴趣.从前上帝创造了我们,现在轮到我们来创造自己的软件了~ 陈彦 ...
- Java细粒度锁实现的3种方式
最近在工作上碰见了一些高并发的场景需要加锁来保证业务逻辑的正确性,并且要求加锁后性能不能受到太大的影响.初步的想法是通过数据的时间戳,id等关键字来加锁,从而保证不同类型数据处理的并发性.而java自 ...
- 配置maven
http://www.cnblogs.com/liunanjava/archive/2015/11/05/4936037.html