zoukankan      html  css  js  c++  java
  • junit启动tomcat来进行单元测试

    1.pom.xml配置下载需要的jar。

        <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.11</version>
                <scope>test</scope>
            </dependency>
              <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>3.2.3.RELEASE</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>3.2.3.RELEASE</version>
            </dependency>

    2.然后在所需要测试的类上加上以下内容:

    @RunWith(SpringJUnit4ClassRunner.class)  
    @ContextConfiguration(locations = "classpath*:spring.xml") //spring.xml是tomcat加载配置文件的入口

    public class MyTest {
       
        @Test
        public void testSearch() {
      
        }

    }

  • 相关阅读:
    ES6 对Math对象的扩展
    ES6 对Number的扩展
    monolog 应该是世界上最好的日志插件了
    ES6 解构赋值的常见用途,很强大
    ES6 对象的解构赋值
    ES6 数组的解构赋值
    ES6 const
    laravel相关插件
    c++ 库 boost安装
    Eclipse ftp插件
  • 原文地址:https://www.cnblogs.com/aisam/p/4813177.html
Copyright © 2011-2022 走看看