Forum Discussion

teak's avatar
teak
Contributor
10 years ago

Environment handling

Is there a way to have the domain of my endpoints variable?   like in postman I would set a {{url}} parameter which i could set different environments.    I would like to run the tests after a bu...
  • kondasamy's avatar
    kondasamy
    10 years ago

    Not sure if I am correct, I guess there is no such option in SoapUI OS for maintaining centralized endpoint. But, there is a workaround which I can suggest,

     

    • Create a Project level - Custom Property called Endpoint and then map your URL as the value for the parameter.
    • Then copy the below Groovy code in a Groovy Test step and Run it.

     

    def endpoint = '${#Project#Endpoint}'
    testRunner.testCase.testSuite.project.testSuites.each
    {
        suite ->
        suite.getValue().testCases.each
        {
            tc->
            tc.getValue().testSteps.each
            {
                it->
                if (it.getValue().config.type.equals("restrequest"))
                {
                     it.getValue().getHttpRequest().setEndpoint(endpoint); 
                }
            }
        }
    }
    log.info("Done")

     

     

    Now all your REST test steps would have the endpoint value set as 

    ${#Project#Endpoint}

    Hope this helps you!

     

    Thanks,

    Samy