Forum Discussion

suchindrac's avatar
Occasional Contributor
15 years ago

How to set testCase endpoints using Groovy Scripts?

Hi All,
          How do we set testCase Endpoints using Groovy Scripts?

          In soapui, this is visible as "Request URL" in the top

4 Replies

  • SmartBear_Suppo's avatar
    SmartBear Alumni (Retired)

    The easiest way to manage your endpoint via a Groovy script is probably by creating a TestCase Test Property for it and using a Property Expansion. For example, create a new Test Property in the TestCase named "endpoint" and set the actual endpoint of the request to ${#TestCase#endpoint} (if you will be using the same endpoint for other testcases you may wish to make it a property on TestSuite level or even Project level instead). To change this property in a Groovy TestStep use:['endpoint'].setValue('new endpoint')

    • PramodYadav's avatar

      SmartBear_Suppo Wonder why no one gave Kudos to this reply yet. Here it goes :). Kudos !


      As an additional note. if you want to use the endpoint url from a parameter defined at say TestSuite level, just change the TestCase to TestSuite in the endpoint url space. Something like this:




      Where, GetTxsEndPointUrl is a custom property i created at TestSuite level. If all your requests now have this formula at end point Url, there is no need to set, reset urls at test step level. Hope this helps to others. 


      Cheers, Pramod

  • Buschfunk's avatar
    Frequent Contributor
    I'm using the following code to set the endpoint for a request:


    The name of the test request which endpoint you'd like to change.

    A string representing the new endpoint, e.g. "http://localhost"