Ask a Question

Environment handling

SOLVED
teak
Contributor

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 build for a particular environment[url]

 

Thanks, 

teak

8 REPLIES 8
sburkard
Occasional Contributor

We use the provided testrunner.sh shell script in the SoapUI/bin folder. You can give it for every run an individual endpoint with the -e switch that overrides ALL endpoints set in the individual teststeps of the project (but only for this run). 

 

There are plenty of other options like username etc., see here for all of them: 

http://www.soapui.org/test-automation/running-from-command-line/functional-tests.html

 

We trigger the soapUI tests nightly with Jenkins, you can also switch on options to generate reports in JUnit format so that the results of the tests are directly shown in Jenkins. 

 

 

Another possibility would be the centralized endpoint example on this page (scroll down to centralized endpoint title)

http://www.soapui.org/functional-testing/properties/working-with-properties.html

 

Regards

Stephan

 

 

Hi Stephan thanks for you reply, 

 

maybe this is a different question for a new thread but: 

For the centralized endpoint example, 

do you know where the "Service Endpoints" tab is for the project?

It is not available in my project view. 

 

Thanks again

kondasamy
Regular Contributor

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

Thanks very much Sammy, 

yeah maybe the Service Endpoints are only for the Pro version. 

Your sollution works nicely. 

Thanks Stephan, 

I will look into setting some options on build. 

I am using TeamCity as a build tool. 

sburkard
Occasional Contributor

Hi teak

 

The "Service Endpoints" tab is not in the project view, but in the interface view (see Screenshot). It is very handy since you can there maintain all your endpoints and use the "Assign" button to switch "all requests and test requests" in one click to another endpoint. 

 

But with or without this tab, the centralized endpoint solution works exactly as Samy has written, with Project level properties.

 

Regards

Stephan

 

Aha found it thanks. 

I have a bit to go through now. 

Will post back if I use another method. 

Thanks again guys. 

HeikoStudt
Occasional Contributor

You can use Property Expansion also in the Endpoint URL:

http://localhost:${#Project#PortQuery}/Query

So we can set all our ports in Project with the option "-P PortQuery=1234"

 

It is pretty cool

 

 

MFG (Best Regards)

Heiko Studt

cancel
Showing results for 
Search instead for 
Did you mean: