Forum Discussion

pavanagadi's avatar
pavanagadi
New Contributor
14 years ago

Integarte JUNIT and SOAPUI

HI, I have written this code in ECLIPSE IDE for JUNIT

SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
runner.setProjectFile("C:\\Documents and Settings\\pavankumar.sa\\Desktop\\Getting-Started-soapui-project.xml");
runner.setPrintReport(true);
runner.run();

On running this code I am not able to get the results.There was a Failure while running this JUNIT code.
The Failure Trace is:


java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser
at com.omig.soapUISamples.Sample.testRunner(Sample.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
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:50)
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)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.CommandLineParser
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 24 more
can anybody help me regarding this..


How Can i resolve this...

Please help me..

Thanks In Advance
Pavan

2 Replies

  • I have the same issue. I have included the full source for the test case, and the dependencies section of the POM.

    The issue is that the pom for eviware.soapui does NOT include any of the transitive dependencies for soapui, and as a result, maven does not know which jars to pull down from the repository and include in the classpath.

    I've seen other posts on this, so hopefully SmartBear can get a 4.0.2 update out with a corrected pom so we can integrate soapui with junit in a maven project.

    Michael

    Full Code of test:

    /**
    * Copyright (c) 2012 Choice Hotels International, Inc.
    *
    * @author mgiroux
    *
    * @version $Id: $
    *
    */

    package com.choicehotels.cis.soapui.guest;

    import static org.junit.Assert.fail;

    import org.junit.Test;

    import com.eviware.soapui.tools.SoapUITestCaseRunner;

    /**
    *
    */
    public class CreateAccountTest {

    /**
    * Create an account for use in subsequent test cases.
    * @throws Exception
    */
    @Test
    public void createAccount() throws Exception {
    SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
    runner.setProjectFile("");
    runner.run();
    }

    }



    The code resides in a maven project. The dependencies section of the POM.XML follows:

    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <scope>compile</scope>
    </dependency>
    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.17.0</version>
    <scope>compile</scope>
    </dependency>
    <dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.6</version>
    <type>jar</type>
    <scope>compile</scope>
    </dependency>
    <dependency>
    <groupId>eviware</groupId>
    <artifactId>soapui</artifactId>
    <version>4.0.1</version>
    <type>jar</type>
    <scope>test</scope>
    </dependency>

    </dependencies>