Reference another project in SoapUI

We all know and love the great freeware tool SoapUI to test web and rest services and do other nifty groovy stuff. You can build big testsuites to make sure your software keeps running and the keeps working the way you want it to work. When building these testsuites you often do the same calls because to need to retrieve data and get all the things you need to build your test. You can copy the steps you need from previous tests but wouldn’t it be nicer and more convenient if we had a generic test in a Util-project which did all that for us? You can achieve this by writing some Groovy script to call the other project and run you specific test. This is how it works:

Make a generic Util-project in SoapUI and put in here a TestSuite and TestCase which does the thing you would like to do more often. Save the project and now create a second project. Add a TestSuite and TestCase and add a Groovy step. This is where all the magic happens:

import com.eviware.soapui.impl.wsdl.WsdlProject

// TESTCASE SPECIFIC PARAMETERS--------------------------------------------------------------------

def workorderDate   = '01-01-2014'
def startTime       = '12:00'
def endTime         = '14:00'

// DO NOT EDIT AFTER THIS SECTION. ONLY COPY--------------------------------------------------------

//get the Util project 
def project = null
def workspace = testRunner.testCase.testSuite.project.getWorkspace();

//if running Soapui
if(workspace != null){
            project = workspace.getProjectByName("Util-project")
//if running in Jenkins/Hudson
            project = new WsdlProject("../../Util-project-soapui-project.xml");

//make a connection to the Util project
if( && == "Util-project" ) {
            def properties = new ()
            //Setup de mock WSDLs
            def testCase = project.getTestSuiteByName("MakeWorkorderReservation").getTestCaseByName("MakeWorkorderReservation"); 
            if(testCase == null)
                        throw new RuntimeException("Could not locate testcase 'MakeWorkorderReservation'! ");
                        //update the variables of the testcase with your specific values
                        testCase.setPropertyValue("WorkorderDate", workorderDate )
                        testCase.setPropertyValue("WorkorderStartTime", startTime)
                        testCase.setPropertyValue("WorkorderEndTime", endTime)
                        //run the testcase
                        def runner =, false);
                        //retrieve the workorderId from the just executed run
                        def workorderId = testCase.getPropertyValue("WorkorderId");
                        //set this value in your own testcase which can be used
                        testRunner.testCase.setPropertyValue("WorkorderId",  workorderId )
            throw new RuntimeException("Could not find project 'Utility-project' !")

In this example we have a Utility-project which has a TestSuite and TestCase with callout which is called: ‘MakeWorkorderReservation’. Guess what is does……it makes a workorder reservation and takes 3 parameters. A date, a start time and a end time. When successful it returns a workorder ID. In our own testcase we need an existing workorder with its ID so we call this groovy script. You can see we set the date, start time and end time and retrieve the workorderId at the end which we can use in our call now.

So if we need another workorder in another testcase/suite, we can just re-use this piece of code to make another one and not keep copying the same calls every time.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.