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 ...
随机推荐
- Unity XLua 官方案例学习
1. Helloworld using UnityEngine; using XLua; public class Helloworld : MonoBehaviour { // Use this f ...
- python 把txt文件分隔成0.8和0.2的比例的新文件
from math import sqrt import randomimport osfrom sklearn import cross_validation os.chdir("/*&q ...
- onItemLongClick+onCreateContextMenu实现长按ListItem弹出不同菜单
个ListActivity,长按不同的item弹出的菜单不一样 参照
- 系统批量运维管理器paramiko详解
一.paramiko介绍 paramiko是基于Python实现的SSH2远程安全连接,支持认证及密钥方式.可以实现远程命令执行.文件传输.中间SSH代理等功能,相对于Pexpect,封装的层次更高, ...
- php function 按引用返回一个值
按引用返回一个值,而不是按值返回,这样就无需为变量建立一个重复的副本 function &array_find_value($needle, &$haystack) { foreach ...
- C语言中的undefined behavior
参考: http://www.cnblogs.com/aoaoblogs/archive/2010/08/31/1813982.html
- [Selenium]Turn Page By Scroll Bar
Description: Need to turn page by operating scroll bar and find out the element in the current page. ...
- 分布式java应用基础与实践
始读于2014年4月30日,完成于2014年6月6日15:43:39. 阿里巴巴高级研究员林昊早年的书了,这些理论放到今天估计工作一两年的人都耳熟能详了,我个人很早以前就知道此书一直没有找到资源, ...
- RabbitMQ的一些说明
下载安装包后,运行会提示你下再ErLang环境,根据提示下载安装就可以了 RabbitMQ 自己的插件包中带一 个WebUI的管理工具,在RabbitMQ安装目录(bin)下运行 rabbitmq-p ...
- eclipse find 两位数
查找两位数