» 您尚未 登录   注册 | 社区服务 | FTP中心 | 帮助 | 社区 | 无图版 | 测试百科  | 测试Blog 
软件测试基地论坛 -> 测试开发技术 -> [求助]StrutsTestCase找不到web.xml
 XML   RSS 2.0   WAP 

--> 本页主题: [求助]StrutsTestCase找不到web.xml 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题
llc2005




该用户目前不在线
级别: 测试新手
精华: 0
发帖: 32
基地声望: 13 点
基地币: 6665 Bug
基地贡献: 0 点
好评度: 0 点
在线时间:12(小时)
注册时间:2005-11-28
最后登录:2006-02-09
查看作者资料 发送短消息 推荐此帖 引用回复这个帖子

[求助]StrutsTestCase找不到web.xml

有一文章这样说:

StrutsTestCase例子里没有使用ant,因此它的运行较让人头痛,特别是有关配置文件的处理。StrutsTestCase在运行时必须能够找到struts-config.xml和web.xml文件,默认的位置是web-inf/目录下,所以web-inf目录要存在于classpath或者在运行的时候指定。例如:我的位于d:/struts-test/下,struts-config.xml和web.xml位于d:/struts-test/webapp/WEB-INF/下,那么在运行测试的时候应当把d:/struts-test/webapp路径放到classpath里。如果我的struts-config.xml不在/web-inf目录里,而是在/web-inf/conf/目录下,那么就须调用setConfigFile(String path)方法

我调用了该方法:
protected void setUp() throws Exception {
    super.setUp();
    articleAction = new articleAction();
    setConfigFile("F:/ABC/ABC/WEB-INF/struts-config.xml") ;
    setConfigFile("F:/ABC/ABC/WEB-INF/web.xml") ;
  }

编译后执行,但依然和之前一样显示同样的错误信息:
junit.framework.AssertionFailedError: The /WEB-INF/web.xml was not found.

我又加断点再执行,发现无论我断点加在哪儿,他都无视断点的存在而执行,然后报同样的错误信息

[楼 主] | Posted: 2005-12-22 10:11 顶端
llc2005




该用户目前不在线
级别: 测试新手
精华: 0
发帖: 32
基地声望: 13 点
基地币: 6665 Bug
基地贡献: 0 点
好评度: 0 点
在线时间:12(小时)
注册时间:2005-11-28
最后登录:2006-02-09
查看作者资料 发送短消息 推荐此帖 引用回复这个帖子



为什么我加的断点丝毫不起作用,难道是这个错误是发生在执行这个类之前?
那么会不会是StrutsTestCase的运行机制是在运行测试类之前先去找struts-config.xml和web.xml文件,
可又不对啊,如果那样加setConfigFile(String path)方法就没用了呀

[1 楼] | Posted: 2005-12-22 10:15 顶端
llc2005




该用户目前不在线
级别: 测试新手
精华: 0
发帖: 32
基地声望: 13 点
基地币: 6665 Bug
基地贡献: 0 点
好评度: 0 点
在线时间:12(小时)
注册时间:2005-11-28
最后登录:2006-02-09
查看作者资料 发送短消息 推荐此帖 引用回复这个帖子



ok,被我猜到了,果然是StrutsTestCase在运行测试类之前先去找struts-config.xml和web.xml文件,
WEB-INF应该放在工程的根目录下

[2 楼] | Posted: 2005-12-22 13:08 顶端
蝙蝠




该用户目前不在线
级别: 测试新手
精华: 3
发帖: 20
基地声望: 21 点
基地币: 6645 Bug
基地贡献: 2 点
好评度: 0 点
在线时间:16(小时)
注册时间:2005-10-27
最后登录:2006-11-12
查看作者资料 发送短消息 推荐此帖 引用回复这个帖子



NOTE: By default, the Struts ActionServlet will look for the file WEB-INF/struts-config.xml, so you must place the directory that contains WEB-INF in your CLASSPATH. If you would like to use an alternate configuration file, please see the setConfigFile() method for details on how this file is located.
摘自:http://strutstestcase.sourceforge.net/
如果你的WEB-INF包括在d:\yourproject\web中,你需要把d:\yourproject\web加入您的classpath.
我是学习日记开发小组:http://www.learndiary.com ,http://develop.learndiary.com .这里有一个完整的“argouml+eclipse+struts+strutstestcase+junit(测试驱动)”的开源小程序,
http://www.learndiary.com/download/learndiary_login.zip
你可以参考一下,顺便提点意见和建议。谢谢。

[3 楼] | Posted: 2005-12-24 10:10 顶端

软件测试基地论坛 -> 测试开发技术




软件测试基地上海测仕信息技术有限公司旗下网站
Copyright © 2005-2007 Cntesting.com, All Rights Reserved
沪ICP备06057721号

Powered by PHPWind Code © 2003-06 PHPWind
Total 0.153746(s) query 5, Time now is:12-04 15:10, Gzip disabled
You can contact us


每日一句:Loading...