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() {
  
    }
}
junit启动tomcat来进行单元测试的更多相关文章
- junit+mock+spring-test构建后台单元测试
		from:从0开始,构建前后端分离应用 1. 一些基本概念 1.1 为什么要进行单元测试?我自己的理解是 1.能够快速发现问题.避免衍生BUG的出现 在对一些现有代码进行修改时,或者修改现有B ... 
- eclipse启动tomcat无法访问
		eclipse启动tomcat无法访问 症状: tomcat在eclipse里面能正常启动,而在浏览器中访问http://localhost:8080/不能访问,且报404错误.同时其他项目页面也不能 ... 
- Error configuring application listener of class。。。NoClassDefFoundError。。某Listener  之启动tomcat报错
		当你启动tomcat的时候如果报类似下面的错误: WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to ' ... 
- eclipse启动tomcat, http://localhost:8080无法访问
		原地址 症状: tomcat在eclipse里面能正常启动,而在浏览器中访问http://localhost:8080/不能访问,且报404错误.同时其他项目页面也不能访问. 关闭eclipse里面的 ... 
- Eclipse启动Tomcat时发生java.lang.IllegalArgumentException: <session-config> element is limited to 1 occurrence
		在学习struts 2时,为了方便,直接从下载的struts的apps目录下的struts2-blank.war压缩包下的WEB-INF\复制的web.xml,当我启动Tomcat时,发生 java. ... 
- Mac下没有权限启动tomcat的解决办法
		问题描述 在Mac中通过./startup.sh执行启动脚本文件,启动tomcat时报如下错误: -bash: ./startup.sh: Permission denied 解决方法 错误信息说明了 ... 
- maven 项目启动tomcat报错 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
		maven项目启动tomcat报错: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderLi ... 
- 直接启动tomcat时为tomcat指定JDK
		第一种: 在windows环境下以批处理文件方式启动tomcat,只要运行<CATALINA_HOME>/bin/startup.bat这个文件,就可以启动Tomcat.在启动时,star ... 
- [转]Eclipse启动Tomcat时45秒超时解决方法
		原文地址:http://it.oyksoft.com/post/6577/ Eclipse启动Tomcat时,默认配置的启动超时时长为45秒.假若项目启动超过45秒将会报错.两种解决方法:1.改XML ... 
随机推荐
- IOS CGAffineTransform 用于视图平移,放缩,旋转
			转载于:http://blog.csdn.net/lc_obj/article/details/17454825 CGAffineTransform 今天碰到了一个旋转放缩图片的一个demo,在看的过 ... 
- oracle数据库在sys下直接修改用户密码
			首先用sys登录上去, 在命令窗口或者是能执行输入sql语句的地方输入下面代码, 回车就好 alter user you_username(要修改的用户名) identified by you_pas ... 
- 关于ErrorPage
			JSP里创建一个网页test.jsp, 让这个网页上面出现一个错误, 再创建一个切换页面error.jsp, 使test.jsp如果出现错误就切换到error.jsp上, 但是怎么试都是出现一个网页上 ... 
- 119. Pascal's Triangle II (Graph; WFS)
			Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ... 
- mysql 求2个坐标之间的距离
			CREATE DEFINER=`root`@`%` FUNCTION `f_GetDistance`(lng1 DOUBLE,lat1 DOUBLE,lng2 DOUBLE,lat2 DOUBLE) ... 
- Spring IoC入门
			------------------siwuxie095 Spring IoC 环境搭建 1.先下载相关库文件,下载链接 ... 
- iOS下nil 、NULL、 Nil 、NSNull的区别
			1.nil,定义一个空的实例,指向OC中对象的空指针. 示例代码: NSString *someString = nil; NSURL *someURL = nil; id someObject = ... 
- 10 Examples of HotSpot JVM Options in Java[z]
			There are hundreds of JVM parameters or JVM Options exists inside sun JDK and its virtually impossib ... 
- requests.session之set trust_env to disable environment searches for proxies
			import requests s = requests.Session() s.trust_env = False This will prevent requests getting any in ... 
- Greeplum 系列(八) 数据维护
			Greeplum 系列(八) 数据维护 一.事务管理 begin(start transaction) # 开始事务 savepoint # 保存事务回滚点 rollback # 回滚事务 end(c ... 
