Getting Class Not found Exception when try to run test in eclipse

253 Views Asked by At

I am Creating Test Automation Script for web application. I want to write test caes for JSP file. For JSP i am using JwebUnit library. i created test file as follows:

class Junittest {

@Before
public void prepare() {
         setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);        
         setBaseUrl("http://localhost:8081/JSPServer/jsp/");        
      }     
@Test       
public void test() {
            beginAt("home.jsp");        
            assertTitleEquals("Echoing HTML Request Parameters");
         }
}

when i try to run JUnit test it is giving me exception as follows :

java.lang.NoClassDefFoundError: org/apache/regexp/RESyntaxException
at net.sourceforge.jwebunit.junit.JWebUnit.getTester(JWebUnit.java:62)
at net.sourceforge.jwebunit.junit.JWebUnit.beginAt(JWebUnit.java:167)
at serv.Junittest.test(Junittest.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:389)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:167)
at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)

I put home.jsp file in JSPServer -> webcontent -> jsp.

when i try to run file on server it is working correctly. When i try to run the JUnit test it is giving above exception.so can anyone suggest me solution for this ?

1

There are 1 best solutions below

0
On

It is missing a library in its build path (best guess Jakarta Regexp jar). Add the jar to your build path. Might just solve your problem.