Forum Discussion

CBS_Interactive_1's avatar
CBS_Interactive_1
Occasional Contributor
14 years ago

Environment Endpoint Property Expansion Syntax

First, a bit of context. I've created a REST test in which I'd like to swap out endpoints to run the same test against different environments. While doing so I noticed that when I assign an endpoint to 'All Requests and All TestRequests' the endpoint isn't always applied to all Test Requests as it does for a SOAP test. This has several adverse effects, one being that I'm never quite sure whether or not all of my test cases are running against the correct environment, and two, the XPath Assertions and Property Transfers often fail because the namespace is hard coded to whatever environment I created the test with.

To circumvent these issues, I've created a custom property in my Test Suite called "Endpoint" in which I manually enter the Endpoint location. Then I use the following property expansion
${#TestSuite#Endpoint}
and apply it to all of my Property Transfers and Assertions. Not as seamless as I'd like it to be but it works. However I've recently come to find out that there is an Environment property expansion option and I'd like to use that instead. What I'm trying to do is pull the endpoint from the active environment that I applied from my Test Suite but I don't know the proper syntax.

I tried
${#Env#Endpoint}
but that didn't work. I've attempted to follow read the documentation as well but have no experience with either Java or Groovy so I found it difficult to follow. Can anyone help?!

2 Replies

  • Hi,

    There might be a misunderstanding here - the #Env# prefix is used to refer to system environment variables and not to variables in the new environment functionality in 4.5.

    Does that make sense?

    regards!

    /Ole
    SmartBear Software
  • CBS_Interactive_1's avatar
    CBS_Interactive_1
    Occasional Contributor
    Please pardon my noobness but I didn't realize that there was a difference between the two. I guess I should ask a more direct question then. Is there any way to assign the currently active TestRequest endpoint to a TestSuite Custom Property via Groovy or some other means? I've been attempting to take a crash course in Java/Groovy in order to decipher the javadoc to no avail so a brief, simple explanation along with some sample code would help tremendously.

    Thanks in advance for your help with this.