博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring的测试
阅读量:7240 次
发布时间:2019-06-29

本文共 2082 字,大约阅读时间需要 6 分钟。

spring测试要引用junit及spring-test

junit
junit
${junit.version}
test
org.springframework
spring-test
${spring.version}
test

代码:

配置文件的引入:

单个文件:@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;    @org.junit.Test    public void deptSelectTest() {        DeptDto model= deptService.getOneById("2");        Assert.assertTrue(model.getId().equals("2"));    }    @org.junit.Test    public void updateTest(){        DeptDto model= new DeptDto();        model.setId("2");        model.setName("111");        deptService.update(model);        String id=model.getId();    }    @org.junit.Test    public void pageTest(){        QueryPage page=new QueryPage(1,5);        ServiceResultT
resultT= deptService.getList(page); } @org.junit.Test public void deleteTtest(){ ServiceResult result= deptService.deleteById("1203"); } @org.junit.Test public void updateDbTest(){ }}

 

如果我的文章对你有帮助,就点一下推荐吧.(*^__^*)
 

转载于:https://www.cnblogs.com/gscq073240/articles/6291404.html

你可能感兴趣的文章
system generator学习笔记【01】
查看>>
基础002_V7-CLB
查看>>
Joseph UVA 1452 Jump
查看>>
学习进度
查看>>
浅析JavaScript事件流——冒泡
查看>>
学习运维决心书
查看>>
计算中英文混合字符串的宽度
查看>>
MASM32_SDKv10以及一些帮大家打包的东西
查看>>
关于配置cordova的一些细节
查看>>
OpenJudge/Poj 2105 IP Address
查看>>
一分钟了解Allegro导入DXF文件
查看>>
Jenkisn call Psexec
查看>>
山东理工ACM【1532】矩阵输出
查看>>
IE9访问EBSR12排版格局错位(uttons and Text Misalignment in FWK pop-ups)
查看>>
JavaScript对象的浅拷贝与深拷贝
查看>>
SpringMVC学习笔记:表单提交 参数的接收
查看>>
idea全局设置
查看>>
Digital Color Meter 颜色值提取工具
查看>>
动态规划——Remove Boxes
查看>>
测试用例设计--因果图
查看>>