测试一般是测试的局部功能,使用时需要自己写个测试相关的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. Excel导入CSV文件中文乱码

    参考: iconv -f UTF8 -t GB18030 a.csv >b.csv 或iconv -f UTF-8 -t GB18030 a.csv >b.csv

  2. [LeetCode&Python] Problem 830. Positions of Large Groups

    In a string S of lowercase letters, these letters form consecutive groups of the same character. For ...

  3. VS、ReSharper 设置修改代码颜色、提高代码辨识度!附VS超实用快捷!

    ReSharper 配置代码颜色 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心 ...

  4. Automatic Text Difficulty Classifier Assisting the Selection Of Adequate Reading Materials For European Portuguese Teaching --paper

    the system uses existing Natural Language Processing (NLP) tools, a parser and an hyphenator, and tw ...

  5. Autofac解耦事件总线

    事件总线之Autofac解耦 事件总线是通过一个中间服务,剥离了常规事件的发布与订阅(消费)强依赖关系的一种技术实现.事件总线的基础知识可参考圣杰的博客[事件总线知多少] 本片博客不再详细概述事件总线 ...

  6. Layer 弹出页面 在点击保存关闭弹出层

    <script src="http://apps.bdimg.com/libs/jquery/2.0.0/jquery.min.js"></script> ...

  7. wekpack笔记

    1. webpack 是一个用来构建我们应用程序中的 JavaScript 模块的工具: 2. 可以从CLI 或 API来开始使用 webpack.这里只讲从CLI来使用它: 3. 安装,需要在nod ...

  8. Go Example--常量

    package main import ( "fmt" "math" ) const s string = "constant" //定义字 ...

  9. 访问 iframe 内部控件方法

    方法虽然简单,但是经常忘记,网上一查,很多方法兼容性都有问题,这段代码至少兼容IE和Chrome setInterval(function(){ document.getElementById('ma ...

  10. C++问题汇总

    1.C++中类相互调用注意事项 (1)若A类中的方法需要调用B类中的函数,那么A类的源文件(或头文件)中需要包含B类的classs声明头文件.若使用了命名空间,还需要在B类的源文件(或头文件)中使用 ...