summernight 发表于 2006-3-16 15:12:09

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:00

请问LZ现在找知道原因吗?我也跟你一样,但是我用了你这个方法还是空指针,你能帮我看下是什么原因吗?如果可以的话麻烦加下我的QQ:441079060 感激不尽
页: [1]
查看完整版本: MockStrutsTestCase中addRequestParameter的小疑问!!