Forum Discussion

teak's avatar
teak
Contributor
9 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 build for a particular environment[url]

 

Thanks, 

teak

  • 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

  • sburkard's avatar
    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

     

     

    • teak's avatar
      teak
      Contributor

      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's avatar
        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

    • teak's avatar
      teak
      Contributor

      Thanks Stephan, 

      I will look into setting some options on build. 

      I am using TeamCity as a build tool. 

  • HeikoStudt's avatar
    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