Forum Discussion

kamahade's avatar
kamahade
Regular Contributor
15 years ago

Groovy script outside SOAPUIPRO project

Team,
I want to run a groovy script outside soapui and in that script I want to create a project, add testsuite,add testcases.

For running a groovy within SOAPUI tool, I could run either as
script assertion
script step
both these should be within a testcase. Also, I could add a script function and place it in particular folder and refer it.
However, if I want to run a groovy outside SOAPUI project, how do I do it ?

Which jar files, I should place in path to do it from Groovy console??
if I run a single line program in groovy console, I get below error
D:\\groovy\cmd_line_soapui>groovy -cp "D:\Program Files\eviware\soapUI-Pro-3.5.1\bin\soapui-pro-3.5.1.jar" trial.gy

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
D:\\groovy\cmd_line_soapui\trial.gy: 1: unable to resolve class com.eviware.soapui.impl.wsdl.WsdlProject @ line 1, column 1.
import com.eviware.soapui.impl.wsdl.WsdlProject;
^
1 error


trial.gy has only one line import com.eviware.soapui.impl.wsdl.WsdlProject;

I tried modifying groovy-starter.conf file as well

I want to automatically

create a project,
add WSDL,
add testsuite for each operation
add several test steps to each of my testcase


I want to do all this through a groovy script. Groovy script may be run only inside a SOAPUI project ?

7 Replies

  • Hello,

    SoapUI PRO builds on top of soapUI, and both have several other dependencies which are required to work. For your script to function you need to include ALL the jar files in the libs folder, not just soapui-pro.

    For example:

    D:\\groovy\cmd_line_soapui>groovy -cp "D:\Program Files\eviware\soapUI-Pro-3.5.1\bin\soapui-pro-3.5.1.jar;D:\Program Files\eviware\soapUI-Pro-3.5.1\lib\*" trial.gy


    Regards,
    Dain
    eviware.com
  • kamahade's avatar
    kamahade
    Regular Contributor
    Thanks.. But am getting still same error message.

    What mistake am doing here ?
  • Hello,

    This is a different error than the first one, it looks like you're forgetting to import the SoapUIProTestCaseRunner class in your script:


    import com.eviware.soapui.SoapUIProTestCaseRunner


    Regards,
    Dain
    eviware.com
  • kamahade's avatar
    kamahade
    Regular Contributor
    Thanks Dain.. I have imported soapuiprotestcaserunner class, but still am getting same error message..
  • Hello,

    The reason that you're getting this error is that you're running code in the body of a class definition, which is not allowed. Either remove the class declaration, making it a script, or move the code to a method inside the class:



    import ...
    import ...
    import ...
    import ...

    def myrunner = new SoapUIProTestCaseRunner();
    myrunner.set...
    myrunner.set...
    myrunner.set...
    myrunner.run();



    Regards,
    Dain
    eviware.com
  • kamahade's avatar
    kamahade
    Regular Contributor
    so much dump I'm...

    for rest of the world.... this would be a sample code to run SOAPUI outside SOAPUI GUI through Groovy..


    import com.eviware.soapui.SoapUIProTestCaseRunner;
    import com.eviware.soapui.support.*;
    import com.eviware.soapui.model.*;
    import com.eviware.soapui.impl.wsdl.*;
    import com.eviware.soapui.*;


    class trial
    {
    public static void main( String[] args ) {
    def t = new trial();
    t.somemethod();
    }
    def somemethod(){
    def myrunner = new com.eviware.soapui.SoapUIProTestCaseRunner();
    myrunner.setProjectFile("D:\\soapui-release-B\\try.xml");
    myrunner.setTestSuite("MediaAssetServiceTestSuite");
    myrunner.setTestCase("getMediaAsset TestCase");
    myrunner.run();
    }
    }


    THANKS ton to support team.... you were really patience enough to help me !!!