spring 整合Junit
主要参考:
https://www.ibm.com/developerworks/cn/java/j-lo-springunitest/
http://www.cnblogs.com/rainisic/archive/2012/01/22/Spring_Test_Framework.html
maven jar:
https://mvnrepository.com/artifact/org.springframework/spring-test/4.3.9.RELEASE
测试代码:
package mydms; import java.util.List; 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;
import org.springframework.transaction.annotation.Transactional; import com.xmal.dms.dao.mapper.AbandonMovingToNewBedMapper;
import com.xmal.dms.pojo.OccupancyInfo;
//下面注释很关键
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/applicationContext.xml")
@Transactional
public class SpringTest { @Autowired
AbandonMovingToNewBedMapper abandonMovingToNewBedMapper;
@Test
public void QueryOccupancyWhereStatusIsTiaoFangTest(){
List<OccupancyInfo> OccupancyInfoList = abandonMovingToNewBedMapper.QueryOccupancyWhereStatusIsTiaoFang("调房");
System.out.println("OccupancyInfoList"+OccupancyInfoList);
}
}
spring 整合Junit的更多相关文章
- spring整合junit报错
1.Could not autowire field: private javax.servlet.http.HttpServletRequest 参考:https://www.cnblogs.com ...
- Spring整合junit测试
本节内容: Spring整合junit测试的意义 Spring整合junit测试 一.Spring与整合junit测试的意义 在没整合junit之前,我们在写测试方法时,需要在每个方法中手动创建容器, ...
- 阶段3 2.Spring_06.Spring的新注解_8 spring整合junit完成
Junit的核心Runner在执行的时候不会创建容器.同时它字节码文件,也改不了 spring整合junit 想办法把junit里面的不能加载容器的main方法换掉.从而实现创建容器.有了容器就可以实 ...
- Spring的AOP开发入门,Spring整合Junit单元测试(基于ASpectJ的XML方式)
参考自 https://www.cnblogs.com/ltfxy/p/9882430.html 创建web项目,引入jar包 除了基本的6个Spring开发的jar包外,还要引入aop开发相关的四个 ...
- SSM框架中测试单元的使用,spring整合Junit
测试类中的问题和解决思路 3.1.1 问题 在测试类中,每个测试方法都有以下两行代码: ApplicationContext ac = new ClassPathXmlApplicatio ...
- 原创:Spring整合junit测试框架(简易教程 基于myeclipse,不需要麻烦的导包)
我用的是myeclipse 10,之前一直想要用junit来测试含有spring注解或动态注入的类方法,可是由于在网上找的相关的jar文件进行测试,老是报这样那样的错误,今天无意中发现myeclips ...
- Spring整合Junit框架
一.开发环境 eclipse版本:4.6.1 maven版本:3.3.3 junit版本:4.12 spring版本:4.1.5.RELEASE JDK版本:1.8.0_111 二.项目结构 图 三. ...
- Spring整合Junit框架进行单元测试Demo
一.开发环境 eclipse版本:4.6.1 maven版本:3.3.3 junit版本:4.12 spring版本:4.1.5.RELEASE JDK版本:1.8.0_111 二.项目结构 图 三. ...
- Spring整合JUnit spring静态对象属性的注入
package cn.itcast.d_junit4; import org.junit.Test; import org.junit.runner.RunWith; import org.sprin ...
- Spring整合JUnit框架进行单元测试代码使用详解
一.Spring提供的JUnit框架扩展: 1. AbstractSpringContextTests:spring中使用spring上下文测试的Junit扩展类,我们一般不会使用这个类来进行单元 ...
随机推荐
- zookeeper3.4.6完全分布式安装
首先在官网下载zookeeper3.4.6安装包,解压到/usr/local目录下 然后改名为zookeeper. 环境变量配置:sudo vim /etc/profile 添加环境变量如下图 然后 ...
- 通过SharpZipLib来压缩解压文件
在项目开发中,一些比较常用的功能就是压缩解压文件了,其实类似的方法有许多 ,现将通过第三方类库SharpZipLib来压缩解压文件的方法介绍如下,主要目的是方便以后自己阅读,当然可以帮到有需要的朋友更 ...
- regex & form validation & phone
regex & form validation https://regexper.com/ https://gitlab.com/javallone/regexper-static https ...
- hibernate笔记(四)
目标: 一.hibernate查询 二.hibernate对连接池的支持 三.二级缓存 一.hibernate查询 1. 查询概述 1) Get/load主键查询 2) 对象导航查询 3) HQL查询 ...
- [Leetcode] String to integer atoi 字符串转换成整数
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...
- 安徽师大附中%你赛day9 T3 贵 解题报告
贵 问题描述 苟先生的狼狗大军没有追上富先生, 所以他把它们都解雇了, 决定去雇佣一些更好的狗, 不过狗可是很贵的.苟先生有 \(w\) 元钱, 有 \(n\) 条狗可以雇佣, 第 \(i\) 条狗有 ...
- 【BZOJ 2822】[AHOI2012]树屋阶梯 卡特兰数+高精
这道题随便弄几个数就发现是卡特兰数然而为什么是呢? 我们发现我们在增加一列时,如果这一个东西(那一列)他就一格,那么就是上一次的方案数,并没有任何改变,他占满了也是,然后他要是占两格呢,就是把原来的切 ...
- [NOI2003] 文本编辑器 (splay)
复制炸格式了,就不贴题面了 [NOI2003] 文本编辑器 Solution 对于光标的移动,我们只要记录一下现在在哪里就可以了 Insert操作:手动维护中序遍历结果,即每次取中点像线段树一样一样递 ...
- POJ2396:Budget(带下界的网络流)
Budget Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 8946 Accepted: 3327 Special ...
- D. Equalize the Remainders (set的基本操作)
D. Equalize the Remainders time limit per test 3 seconds memory limit per test 256 megabytes input s ...