我正在尝试将SoapUI集成到我预先存在的JUnit测试中。我在SoapUI 3.6.1中创建了一个测试。它有效。
我的下一步是将它应用到我的开发环境中。在我的Eclipse项目中,我将jar添加到了我的类路径中。我还创建了以下测试。
public class TestMySoapUICase
{
@Test
public void testCase() throws Exception
{
SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
runner.setProjectFile( "test/java/com/path/Test-soapui-project.xml" );
runner.run();
}
}
此测试看起来非常简单,但在将测试作为JUnit测试运行时,我收到以下异常:
java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser
at com.path.TestMySoapUICase.testCase(TestMySoapUICase.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
似乎还有其他人在运行应用程序时遇到此问题。他们的解决方案是将JAVA_HOME设置为指向jre6而不是jre5。我试过这个(不要指望它起作用),而且,这是正确的;它什么都没改变。
那里有人有解决这个问题的方法吗?
答案 0 :(得分:5)
将soapui_folder / lib(其中soapui_folder - 带解压缩的soapui应用程序的目录路径)添加到项目的类路径中,然后设置为go!
WBR
答案 1 :(得分:2)
在需要添加log4j 1.2.jar之后,需要在此项目中添加commons-cli-1.2.jar文件