获取类 找不到类 尝试在 eclipse 中运行测试时出现异常



我正在为 Web 应用程序创建测试自动化脚本。我想为 JSP 文件编写测试。对于 JSP,我使用的是 JwebUnit 库。我创建了如下测试文件:

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");
         }
}

当我尝试运行 JUnit 测试时,它给我的异常如下:

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)

我把home.jsp文件放在JSPServer -> webcontent -> jsp中。

当我尝试在服务器上运行文件时,它工作正常。当我尝试运行 JUnit 测试时,它给出了上面 exception.so 谁能建议我解决这个问题?

它的构建路径中缺少一个库(最好猜测Jakarta Regexp jar(。将 jar 添加到生成路径。可能只是解决你的问题。

相关内容

最新更新