Re: Basic Unit test for a WW Action?
Alexandru Popescu <[email protected]>
| Newsgroups | gmane.comp.java.open-symphony.webwork |
|---|---|
| Message-ID | <[email protected]> |
Hi!
I am not quite sure what you try to test (because you don't show your action). However, as a
strategy you should decide first what you try to test, for example:
1/ is my action calling the correct service
2/ what happens with my action if the service throws an exception
3/ any other logic you have in the action (this is debatable if it is good or bad :-) ).
hth,
./alex
--
.w( the_mindstorm )p.
#: Ghetto Java changed the world a bit at a time by saying (astral date: 6/13/2006 12:10 AM) :#
> Hello,
> Trying to follow WW in Action I can up with the following unit test method and
> the subsequent exception, I've been searching the forum for example but not having much luck.
> Thanks
> Vinny
>
>
> //
>
> public void testHomeAction() throws Exception {
> HomeAction homeAction = new HomeAction(); // implements ServletRequestAware
> MockHttpServletRequest mockReq = new MockHttpServletRequest();
>
> mockReq.setupAddParameter("name","Vincent");
> homeAction.setServletRequest(mockReq);
> homeAction.execute();
> String attributeValue = (String) mockReq.getAttribute("name") ; //line 44
> assertEquals(attributeValue,"Vincent");
>
>
>
> }
>
>
> ///
>
>
> Test set: com.aaxistechnologies.FirstActionTest
> -------------------------------------------------------------------------------
> Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.069 sec <<< FAILURE!
> testHomeAction(com.aaxistechnologies.FirstActionTest) Time elapsed: 0.058 sec <<< FAILURE!
> junit.framework.AssertionFailedError: attributes has run out of objects.
> at junit.framework.Assert.fail(Assert.java:47)
> at junit.framework.Assert.assertTrue(Assert.java:20)
> at com.mockobjects.ReturnObjectList.nextReturnObject(ReturnObjectList.java:61)
> at com.mockobjects.servlet.MockHttpServletRequest.getAttribute(MockHttpServletRequest.java:62)
> at com.aaxistechnologies.FirstActionTest.testHomeAction(FirstActionTest.java:44)
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=34109&messageID=66312#66312
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]