zoukankan      html  css  js  c++  java
  • @ContextConfiguration注解和@runWith注解作用

    @ContextConfiguration注解
    1 正常使用
    @ContextConfiguration Spring整合JUnit4测试时,使用注解引入多个配置文件

    1.1 单个文件
    @ContextConfiguration(locations="../applicationContext.xml")

    @ContextConfiguration(classes = SimpleConfiguration.class)

    1.2 多个文件
    可用{}

    @ContextConfiguration(locations = { "classpath:/spring1.xml", "classpath:/spring2.xml" })

    1.3 默认不写
    可以根据测试的类名,去找到与之对应的配置文件。
    来源: https://www.cnblogs.com/lixuwu/p/6697537.html

    @runWith注解作用
    @RunWith就是一个运行器

    @RunWith(JUnit4.class)就是指用JUnit4来运行

    @RunWith(SpringJUnit4ClassRunner.class),让测试运行于Spring测试环境

    @RunWith(Suite.class)的话就是一套测试集合

    @runWith注解作用
    @RunWith就是一个运行器

    @RunWith(JUnit4.class)就是指用JUnit4来运行

    @RunWith(SpringJUnit4ClassRunner.class),让测试运行于Spring测试环境

    @RunWith(Suite.class)的话就是一套测试集合,

    @RunWith(SpringJUnit4ClassRunner.class)使用了Spring的SpringJUnit4ClassRunner,以便在测试开始的时候自动创建Spring的应用上下文。其他的想创建spring容器的话,就得子啊web.xml配置classloder。 注解了@RunWith就可以直接使用spring容器,直接使用@Test注解,不用启动spring容器

    注:这里SpringRunner 继承了SpringJUnit4ClassRunner,没有扩展任何功能;使用前者,名字简短而已

    来源: https://blog.csdn.net/qq_43843725/article/details/97100334

  • 相关阅读:
    二叉搜索树的后序遍历序列
    验证二叉搜索树
    合并二叉树
    工龄计算方案
    hadoop集群中动态添加节点
    java知识点
    Hadoop经典案例(排序&Join&topk&小文件合并)
    mysql学习
    大数据开发面试
    我保存的网址
  • 原文地址:https://www.cnblogs.com/anke-z/p/13589494.html
Copyright © 2011-2022 走看看