Forum Discussion

gpeeters's avatar
gpeeters
Occasional Contributor
11 years ago

service endpoint variable at test case level

Hi Support Team,

I'm looking how I can derive the service endpoint url at the moment it is selected in the drop down menu

In my rest replies I receive URL's which contain the base URL which is actually the same as the service endpoint url.
To check the links are on the same platform (dev, test, stage) I need to derive this endpoint variable.

Is this variable available through property expansion? #TestCase#.....

Kind regards,

Geert
  • you will have to use some Groovy to dynamically change the environments, see examples below:

    testRunner.testCase.testSuite.project.setActiveEnvironment("staging")

    The above will set the environment labeled staging

    Let me know if you have further questions.

    Regards,
    Temil
  • gpeeters's avatar
    gpeeters
    Occasional Contributor
    Hi,

    This is not exactly what I'm looking for.

    I need to know the content of the active service endpoint variable.

    Since this contains the service endpoint base URL, which I need to assert in responses.

    My response contains the following element :

    <uri>"serviceEndPointURL"/"other resource"</uri>

    I need to be able to validate "serviceEndPointURL" corresponds with the active service endpoint variable

    Kind regards,

    Geert Peeters
  • Hi,

    Create a testCase level property,
    called service_endpoint


    //Create a script assertion to get the service endpoint and save it in the test case property.
    testRunner.testCase.setPropertyValue( "service_endpoint", messageExchange.getEndpoint())

    // Once you save the endpoint in a property you can access it using the following property
    testRunner.testCase.getPropertyValue( "service_endpoint" )

    //or
    context.expand( '${#TestCase#service_endpoint}' )



    More tips and tricks on coding,

    http://www.soapui.org/Scripting-Propert ... ricks.html


    Thanks,
    Jeshtha