Until release of soapUI 4.5, it was a big pain for end user(tester) to change the enpoint URL for all the testcase/testsuite under a project with single click. The process to change the endpoint (from QA server to PROD server) at project level involved list steps:

– Select a testCase set the endpoint.
– Perform above step for each testCase in a testSuite
– Perform above step for each testSuite under a project.

Now just imagine the ‘pain’ involved if your project contains huge # of TestSuites and/or # of TestCases.

Personally i felt this pain of doing these set of actions  before every release and decide to save my efforts on this. And the result was the following script.

/*
 @Author : Pradeep Bishnoi
 @Description : Setting my customized endpoint URL
@Usage : Place the script in the Project Load/Save script section
*/

def myEndpoint = "http://10.10.101.1/myApplicationAPI/version2.1/service.svc"
 testSuiteList = project.getTestSuites()
 text = "~"
 testSuiteList.each
 {
 testSuite = project.getTestSuiteByName(it.key)
 testCaseList = testSuite.getTestCases()
 log.info " ${text*5} TestSuite :: $testSuite.name"
 testCaseList.each
  {
  testCase = testSuite.getTestCaseByName(it.key)
  log.info " ${text*5} Testcase :: $testCase.name"

  wsdlTestSteps = testCase.getTestStepsOfType( com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep.class )  //only WsdlTestRequest steps
  wsdlTestSteps.each
   {
   //log.info it.properties['Endpoint'].value
   it.properties['Endpoint'].value = myEndpoint
   }
  }
 }

log.info "All the endpoints are now : $myEndpoint"

Above mentioned is the simpler approach of setting the endpoint by hardcoding the endpoint URL in groovy code. Now that can be parameterized by using the single code line :

def myEndpoint = "http://" + "\$" + "{#Project#Endpoint" + "}/myApplicationAPI/" + "\$" + "{#Project#Version}/Service.svc"

and creating 2 project level properties namely “Endpoint” & “Version”. All done!
Keep watching this blogspace for more dosage of Groovy. Till next blog Happy reading & sharing 🙂

Advertisements
Comments
  1. swathi says:

    Hi all,
    I have a question in soapUI pro. I’m working with data driven testing..so used datasource step to link to external xlsx sheet.
    when i try to run that it is throwing me error like this” Unable to recognize OLE stream “.
    I didn’t get exact topic for this, so posting here..

    • Aaron Lau says:

      may you would try to use .csv or .xls suffix instead

    • Hi,
      This might be occurring due to incompatible format of the file.
      i.e., you are trying to read a XLS file which is having .XLSX extension (or created in Excel 2007).
      The library (jxlapi.jar) doesn’t support that format i guess.

      {Pradeep Bishnoi}

      • manoj says:

        Hi Pradeep~

        we do not required jexcelapi.jar , If we want to perform Data driven with data source in SOAPUI PRO and accoding to my assuption SOAPUI Pro does not support .XLSX format it seems

        Thanks
        Manoj

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s