day38 20-Spring与Junit整合

package cn.itcast.test; 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 cn.itcast.service.UserService; @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:applicationContext.xml")//这种方式的好处是不用你自己去加载配置文件了.
//这种测试以后要习惯,结合Spring进行单元测试的时候都会使用这种方式.
public class SpringTest {
@Autowired//想用哪个类直接一注入就行了.
private UserService userService; @Test
public void demo1(){ userService.sayHello();
}
}
day38 20-Spring与Junit整合的更多相关文章
- Spring Test+JUnit整合使用
在做spring相关测试时比较麻烦,如果只用JUnit测试,需要没测有初始化一下applicationContext,效率比较底下,而且也有不足之处.具体见下文 导致多次Spring容器初始化问题 根 ...
- Spring入门(11)-Spring与Junit整合
POM配置 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3. ...
- spring框架学习(三)spring与junit整合测试
package cn.mf.b_test; import javax.annotation.Resource; import org.junit.Test; import org.junit.runn ...
- spring和junit整合
- spring与junit整合测试
1.导包4+2+aop+test 2.配置注解 3.测试
- Spring学习笔记(二)——Spring相关配置&属性注入&Junit整合
一.Spring的相关配置 1.1 Bean元素 class属性:被管理对象的完整类名 name属性:给Bean起个名字,能重复,能使用特殊字符.后来属性 id属性:给Bean起个名字,不能重复,不能 ...
- JAVAEE——spring02:使用注解配置spring、sts插件、junit整合测试和aop演示
一.使用注解配置spring 1.步骤 1.1 导包4+2+spring-aop 1.2 为主配置文件引入新的命名空间(约束) 1.3 开启使用注解代替配置文件 1.4 在类中使用注解完成配置 2.将 ...
- Spring集成JUnit测试
1.程序中有Junit环境2.导入一个jar包.spring与junit整合jar包 spring-test-3.2.0.RELEASE.jar3.测试代码 @RunWith(SpringJUnit4 ...
- Spring 与 MyBatis 整合
一.实验介绍 1.1 实验内容 本节课程将整合 Spring 和 MyBatis,并采用 Junit 进行单元测试. 1.2 实验知识点 Spring - MyBatis 整合 Junit 单元测试 ...
- spring-注解配置-junit整合测试-aop
1 使用注解配置spring 1.1 步骤 导包4+2+spring-aop 1.为主配置文件引入新的命名空间(约束) 2.开启使用注解代理配置文件 3.在类中使用注解完成配置 1.2 将对象注册到容 ...
随机推荐
- hexo_localhost:4000_无法访问
title: 'hexo_localhost:4000_无法访问' date: 2016-05-02 09:38:51 categories: blog tags: [hexo] 问题描述 安装完成h ...
- 新手redis集群搭建
redis集群搭建在开始redis集群搭建之前,我们先简单回顾一下redis单机版的搭建过程 下载redis压缩包,然后解压压缩文件:进入到解压缩后的redis文件目录(此时可以看到Makefile文 ...
- php循环语句(一)
PHP 循环语句 什么是循环语句? 在不少实际问题中有许多具有规律性的重复操作,因此在程序中就需要重复执行某些语句.一组被重复执行的语句称之为循环体,能否继续重复,决定循环的终止条件.循环结构是在一定 ...
- SQLServer-SQLServer2017:SQLServer2017
ylbtech-SQLServer-SQLServer2017:SQLServer2017 微软推出了首个公共预览版本,并持续带来更新和改进.而今天,微软同时向 Windows.Linux.macOS ...
- [转载] DDK中VPORT Mini-Driver的使用说明
学习下. 原文地址:DDK中VPORT Mini-Driver的使用说明作者:跳皮筋的小老鼠 要使用TI DDK中实现的VPORT驱动程序,首先需要在程序中提供VPORT_PortParams类型的参 ...
- redis键(key)
redis键: 用于管理redis的键 command key_name > set runoodkey redis OK > del runoodkey 上面的例子中,del是一个命令, ...
- CentOS 6 忘记root密码的修改方法
1.Linux的root密码修改不像Windows的密码修改找回,Windows的登录密码忘记需要介入工具进行解决.CentOS6和CentOS7的密码方法也是不一样的,具体如下: 2.centos ...
- HDU3374 字符串最大最小表示法模板
一开始没太看懂什么意思,拿笔反复推了一遍才大概知道最大最小表示法是怎么求的,感觉太神奇了... #include <iostream> #include <cstdio> #i ...
- LA3029 City Game
Bob is a strategy game programming specialist. In his new city building game the gaming environment ...
- Luogu P3960 列队(动态开点线段树)
P3960 列队 题意 题目描述 Sylvia 是一个热爱学习的女孩子. 前段时间,Sylvia 参加了学校的军训.众所周知,军训的时候需要站方阵. Sylvia所在的方阵中有\(n \times m ...