Hi Andrew, I have visited Site All sites but not been able to write testCase for Struts Actions. examples they contains of Actions are using Perform method but now we are using execute and Each time i am running testcase i got error.
So can you suggest me what should i do.. I have gone on Cactus Forum but there is not enough discussion on forum Hardly 20-30 people are there and they most of time discussing Cactus plugin for Eclipse.. But i am not able to Write a simple testcase So can Any body help me in this.. public class TestSampleAction extends MockStrutsTestCase { public TestLoginAction(String testName) { super(testName); } public void testSuccessfulLogin() { setRequestPathInfo("/login"); addRequestParameter("username","deryl"); addRequestParameter("password","radar"); actionPerform(); } } [main] INFO util.PropertyMessageResources - Initializing,config='org.apache.struts.util.LocalStrings', returnNull=true [main] INFO util.PropertyMessageResources - Initializing,config='org.apache.struts.action.ActionResources', returnNull=true Time: 0.625 There was 1 failure: 1)testAction(logic.struts.actions.TestFirstAction) junit.framework.AssertionFailedError: Error running action.perform(): classjava.lang.NullPointerException - null at servletunit.struts.MockStrutsTestCase.actionPerform(MockStrutsTestCase.java: 339) at logic.struts.actions.TestFirstAction.testAction(TestFirstAction.java:47) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12) FAILURES!!! -----Original Message----- From: Andrew Geery [mailto:[EMAIL PROTECTED] Sent: Thursday, July 31, 2003 5:59 PM To: Struts Users Mailing List Subject: Re: Struts Test Case (new Bie..) It depends what type of tests you are writing. The cactus site has a discussion about the mock object approach vs. the container approach both on the main page ("Different kinds of unit tests" http://jakarta.apache.org/cactus) and at http://jakarta.apache.org/cactus/mock_vs_cactus.html For examples on how to use strutstestcase, look on the project's website: http://strutstestcase.sourceforge.net/ (The strutstestcase website also has a discussion of mock v. container testing) I would recommend starting with mock objects (they're a little simpler to use, simply because the application server isn't in the picture). Sachin wrote: >Hi All, > >can any body suggest me what is best test case approach to write testcases >for Actions and Forms >Whether it should be MockStrutsTestCase Approach or >CactusStrutsTestCase........ >And where will i get examples on it.. > >Thanks >Sachin > > > >--------------------------------------------------------------------- >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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]