51Testing软件测试论坛

标题: MockStrutsTestCase中addRequestParameter的小疑问!! [打印本页]

作者: summernight    时间: 2006-3-16 15:12
标题: MockStrutsTestCase中addRequestParameter的小疑问!!
各位朋友好!!我是一个JUNIT的测试新手,在一次做struts的action测试中遇到了这样一个问题:

如果这样写:
this.setContextDirectory(new File("WebModule")) ;
this.setRequestPathInfo("/loginAction.do") ;
this.addRequestParameter("name","mm") ;
this.addRequestParameter("pass","mm") ;
this.actionPerform();
this.verifyForward("successPage");
this.verifyForwardPath("/Success.html");
就总是说有错误!!原因是什么呢?


如果这样写:
this.setContextDirectory(new File("WebModule"));
this.setRequestPathInfo("/loginAction.do");
LoginActionForm form = new LoginActionForm();
form.setUserName("mm");
form.setUserPass("mm");
this.setActionForm(form);
this.actionPerform();
this.verifyForward("successPage");
this.verifyForwardPath("/Success.html");
就一点问题都没有了。我很想知道原因是什么!!谢谢各位了!!
我在各处的资料中都看到是我上面的错误写法,为什么我这样做就不对呢?谢谢了:p
作者: JCWHY    时间: 2015-2-8 19:46
请问LZ现在找知道原因吗?我也跟你一样,但是我用了你这个方法还是空指针,你能帮我看下是什么原因吗?如果可以的话麻烦加下我的QQ:441079060 感激不尽




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2