JiveJdon Community Forums
在线392人   首页   主题表   培训咨询   标签   精华   查搜   注册    登陆 RSS
首页 » 论坛 » J2EE/JavaEE/JEE/EJB/JSF等技术讨论
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表
???en_US.forumThreadNext.name??? 下一主题
Go 总共有 2 回复 / 1
 发表新帖子   回复该主题贴
不吃羊肉

悄悄话
发表文章: 30
注册时间: 2002年09月24日 16:50
[ISSUE]how to perform unit testing in J2EE enviornment? 2003年08月06日 14:29 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
标签列表
Hi, guys

i take a look at the doc of Cactus but it seems that the cactus could test only Servlet and EJB etc.

the issue is: if there is some independent tier(for example: Action class in Struts, or Service in OFbiz) in the application.
the essential problem is that all these methods depent on the run-time context such as HttpSession, HttpRequest, etc. how can i perform the unit test? if anybody can provides some guide or frag of codes, i will really appreciate.

am i clear enough? :)
cinc

悄悄话
发表文章: 2
注册时间: 2003年08月06日 09:31
Re: [ISSUE]how to perform unit testing in J2EE enviornment? 2003年08月06日 15:34 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
首先,refactor 你的程序,使这个对象和方法间的耦合变小,特别是把业务相关的方法,从特定的运行环境类里剥离出来,这样可以对业务类单独的做测试。

但是,也确实存在一些对象,和方法,必须在一定的环境里做测试,比如 Struts 的 action ,以前,必须运行起 web 服务器,才可以手工测试它。而如果你想有自动运行的测试,推荐使用 Strutstestcase

还有,不知你有没有听说过 mock object 这个技术,我也是刚接触它其实 Strutstestcase 就是一个很好的 mock object 的实现,它在测试 action 的时候并没有使用真正的 web 环境,而是自己构建了
虚拟的环境,模拟在 web 环境里的 request response,session 等等功能然后在这个虚拟的环境里测试 action

但是,必须考虑的是,建立 mock 环境的工作量也是挺大的。

相关的站点,文章:
structtestcase
http://sourceforge.net/projects/strutstestcase/

mock object 主页:
http://www.mockobjects.com/wiki

这里有篇文章介绍 mock object
ftp://cinc.3322.org/pub/doc/xp/JavaXPCookbook.chm 第六章
(好像第七章是讲 cactus 的)

不吃羊肉

悄悄话
发表文章: 30
注册时间: 2002年09月24日 16:50
Re: [ISSUE]how to perform unit testing in J2EE enviornment? 2003年08月06日 15:51 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
thanks too much!
我之前也考虑过用Mock来做单元测试
可惜,没有时间和精力去研究它的实现机制

strutstestcase确实是我现在最需要的

太感谢了
这个主题有 2 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache 缓存 DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Seam Spring Struts
正在读取,请等待...
google yahoo 新浪ViVi 365Key网摘 天极网摘 CSDN网摘 添加到百度搜藏 POCO网摘 博采网摘
查询本论坛内 回复超过的热门帖子
     回复该主题贴
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
  每2分种自动备份发贴内容Ctrl-V粘贴取出,提问题前先查询标签列表

RSS 手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com

anti spam