测试一般是测试的局部功能,使用时需要自己写个测试相关的spring配置文件,比较费劲,所以常用的是纯配置的方式来实现测试.

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={CustomerServiceTest.class})
@Configuration
@ComponentScan(basePackages={"com.itheima"})
public class CustomerServiceTest { @Autowired
private ICustomerService customerService; @Test
public void testFindAll(){
customerService.findAllCustomer();
} @Test
public void testSave(){
Customer c = new Customer();
c.setCustName("传智学院 ");
customerService.saveCustomer(c);
}
}

测试的demo

spring 整合Junit学习的更多相关文章

  1. spring整合junit报错

    1.Could not autowire field: private javax.servlet.http.HttpServletRequest 参考:https://www.cnblogs.com ...

  2. Spring整合junit测试

    本节内容: Spring整合junit测试的意义 Spring整合junit测试 一.Spring与整合junit测试的意义 在没整合junit之前,我们在写测试方法时,需要在每个方法中手动创建容器, ...

  3. 阶段3 2.Spring_06.Spring的新注解_8 spring整合junit完成

    Junit的核心Runner在执行的时候不会创建容器.同时它字节码文件,也改不了 spring整合junit 想办法把junit里面的不能加载容器的main方法换掉.从而实现创建容器.有了容器就可以实 ...

  4. Spring的AOP开发入门,Spring整合Junit单元测试(基于ASpectJ的XML方式)

    参考自 https://www.cnblogs.com/ltfxy/p/9882430.html 创建web项目,引入jar包 除了基本的6个Spring开发的jar包外,还要引入aop开发相关的四个 ...

  5. SSM框架中测试单元的使用,spring整合Junit

    测试类中的问题和解决思路   3.1.1     问题 在测试类中,每个测试方法都有以下两行代码: ApplicationContext ac = new ClassPathXmlApplicatio ...

  6. 原创:Spring整合junit测试框架(简易教程 基于myeclipse,不需要麻烦的导包)

    我用的是myeclipse 10,之前一直想要用junit来测试含有spring注解或动态注入的类方法,可是由于在网上找的相关的jar文件进行测试,老是报这样那样的错误,今天无意中发现myeclips ...

  7. spring 整合mybatis 学习笔记

    1.1 环境准备 java环境: jdk1.7.0_72 eclipse indigo springmvc版本:spring3.2  所需要的jar包: 数据库驱动包:mysql5.1 mybatis ...

  8. Spring整合Junit框架

    一.开发环境 eclipse版本:4.6.1 maven版本:3.3.3 junit版本:4.12 spring版本:4.1.5.RELEASE JDK版本:1.8.0_111 二.项目结构 图 三. ...

  9. Spring整合Junit框架进行单元测试Demo

    一.开发环境 eclipse版本:4.6.1 maven版本:3.3.3 junit版本:4.12 spring版本:4.1.5.RELEASE JDK版本:1.8.0_111 二.项目结构 图 三. ...

随机推荐

  1. SDM(Supervised Descent Method and its Applications to Face Alignment )

    sdm SDM 人脸对齐的核心内容很简单,就是特征到偏移量的映射:                                           Ix = R I 是特征,x是映射矩阵,R是偏移 ...

  2. base标签对svg的影响

    页面地址:http://127.0.0.1:8080/fullLink_node.html?project_id=2 base:<base href="http://127.0.0.1 ...

  3. 远程办公的GitLab开源的员工手册:涵盖了公司价值观,内部沟通交流指南,开发流程,如何开会,写作风格指南,如何报销,如何请假,线上办公工具推荐等方方面面

    原文 :https://docs.gitlab.com.cn/ce/ 英文 :https://about.gitlab.com/handbook/ GitLab Community Edition G ...

  4. 并发编程-TPL

    并发编程-TPL 本节导航 基本概念 并发编程 TPL 线程基础 windows为什么要支持线程 线程开销 CPU的发展 使用线程的理由 如何写一个简单Parallel.For循环 数据并行 Para ...

  5. L3-019 代码排版 (30 分)

    某编程大赛中设计有一个挑战环节,选手可以查看其他选手的代码,发现错误后,提交一组测试数据将对手挑落马下.为了减小被挑战的几率,有些选手会故意将代码写得很难看懂,比如把所有回车去掉,提交所有内容都在一行 ...

  6. shutil模块(高级的文件、文件夹、压缩包处理模块)

    shutil 模块 高级的 文件.文件夹.压缩包 处理模块 shutil.copyfileobj(fsrc, fdst[, length])将文件内容拷贝到另一个文件中 import shutil s ...

  7. Go Example--通道

    package main import "fmt" func main() { //string类型通道 messages := make(chan string) //往通道写入 ...

  8. mongodb千万级写入怎么优化

    从mysql数据库通过java程序导入单表1300w到mongodb,花了大概50分钟,前1000w条数据中每100w条大概要3分钟,之后的300多w条就差不多每100w条要5到6分钟,之后再从其他的 ...

  9. 使用C语言简单模拟Linux的cat程序

    先给出源码 //fileio.c #include<stdio.h> #include<stdlib.h> #include<fcntl.h> void print ...

  10. Centos7部署ntp服务器同步时间以及直接将本地时间同步为北京时间

    一.查看配置 查看时区列表: timedatectl list-timezones|grep Asia 查看当前时间: date 查看当前设置: [root@localhost ~]# timedat ...