This is the error I get when I run my testcase. There are many who have got this error when I googeled but found no solution.
Unable to initialize Struts ActionServlet due to an unexpected exception or error thrown, so marking the servlet as unavailable. Most likely, this is due to an incorrect or missing library dependency.
public class TestLoginAction extends MockStrutsTestCase{ public void setUp() throws Exception { super.setUp(); } public void tearDown() throws Exception { super.tearDown(); } public TestLoginAction(String testName) { super(testName); }
public void testSuccessfulLogin() { setRequestPathInfo("/login"); addRequestParameter("username","aaa"); addRequestParameter("password","aaa"); actionPerform(); //error here verifyForward("success"); assertEquals("aaa",(String) getSession().getAttribute("authentication")); verifyNoActionErrors(); }
I have
JDK1.5 --RAD6---Struts 1.2.9
all are in Java Build Path (RAD projects--properties-javabuildpath)
Web-inf has to be in classpath of Junit Run ... -> Classpath -> User Entries -> Advanced -> Add Folders, then pick the folder webcontent (it has to point to directory above web-inf, not web-inf )