Forum Discussion

alibaba82's avatar
alibaba82
Super Contributor
17 years ago

automation question

Hello,
I am trying to write a framework so that I can automate the testing of web services. I have been using the groovy script library to accomplish most of my automation. So for instance I have defined my connection string in an external XML file. Within my groovy script I will read this file and do appropriate actions.

I wanted to know if there is any way I can do something similar to dynamically change the endpoints in the request. I have different environments (QA, integration, production) which I would like to point to while running my tests.  for example
in Integration
http://cswebdev.tvguide.com/v2/UserProfileService.asmx
would change to
http://qa-services.tvguide.com/v2/UserP ... rvice.asmx
in QA.

As of now I just open the project file in notepad and do a simple copy/replace and save the file.

Any suggestions, ideas would be appreciated.

5 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    sure, you could create a groovy-script that loops all requests in your tests and sets the endpoint:

    import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep

    def testCase = testRunner.testCase
    for( c in 0..testCase.testStepCount-1 )
    {
      if( testCase.getTestStepAt( c ) instanceof WsdlTestRequestStep )
      {
          testCase.getTestStepAt( c ).testRequest.endpoint = "another endpoint"
      }
    }


    If you need to do this for all testcases/testsuites, just add outer loops for these.

    We will add pre/post processing groovy scripts to testcases / testsuites in soapUI 1.8, which will be a good place to hold this..

    regards!

    /Ole
    eviware.com
  • alibaba82's avatar
    alibaba82
    Super Contributor
    would it be possible to add a pre processing groovy script to the project. The reason is that in this script, we can configure environments which will apply to the entire project.

    Thanks

    Ali
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Ali,

    it's not currently possible, but relatively easy to add.. when would this script be triggered? When loading the project? Or from a menu item?

    regards!

    /Ole
    eviware.com
  • alibaba82's avatar
    alibaba82
    Super Contributor
    I think it would make more sense to trigger this script when loading this project. I typically (based on my project) require 3 things to change

    1. The actual WSDL (integration, dev, QA environments)
    2. username / password for methods (since our services are secured)
    3. any groovy scripts which might access the database (insert, update, etc)

    I was able to solve the third problem very gracefully by writing a outside library using groovy repository feature in soapUI 1.7.5.

    Basically any solution that would allows switching of WSDLs with relative easy would be very helpful. Currently I just use notepad ++ to copy/replace wsdl. However, my ideal scenario would be run a series of test in multiple environments without any manual intervention.
  • omatzura's avatar
    omatzura
    Super Contributor
    Thanks for your clarification.. We'll ponder on this for the next release and I'll get back to you..

    regards!

    /Ole
    eviware.com