zoukankan      html  css  js  c++  java
  • spring整合Junit方法,支持注解

    1, 导入 spring-test-3.2.0.RELEASE.jar   

    2.添加依赖包  项目右键单击BuildPath>AddLibrary>JUnit    选JUnit4  完成.

    3.创建测试类

    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 com.level.service.TestService;
    
    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations="classpath:beans.xml")//加载spring容器配置文件
    public class TestJUnit {
        @Autowired
        TestService testService;
        @Test
        public void test1(){
            testService.save();
        }
    
    }

      

  • 相关阅读:
    LeetCode
    LeetCode
    LeetCode
    位运算实现加法运算
    反转字符串
    数组中的逆序对
    矩阵中的路径
    机器人的运动范围
    滑动窗口的最大值
    HTML5全屏浏览器兼容方案
  • 原文地址:https://www.cnblogs.com/mr-level/p/5133354.html
Copyright © 2011-2022 走看看