BruceyBandit
BruceyBandit

Reputation: 4334

How to display actual value of a property which is using property expansion

I require some help on being able to get around displaying an endpoint from a SOAP Request.

Below I have a piece of code which retrieves an endpoint from a SOAP Request named 'TestAvailability' and outputs it to a file (the code is within a groovy script step).

def endpoint = testRunner.testCase.getTestStepByName('TestStep').get

Now here is the catch, in the file it outputs the endpoint as so:

ENDPOINT: ${#Project#BASE_URL}this_is_the_endpoint

The reason it displays ${#Project#BASE_URL} is because this is a variable set at project level so that the user can select their relevant environment from a drop down menu and that value will be displayed for the variable: ${#Project#BASE_URL}

But I don't want the project variable to be displayed but instead its value like so if ${#Project#BASE_URL} is set to 'testenv'

 ENDPOINT: testenv_this_is_the_endpoint

My question is how do I change the code in order to display the endpoint correctly when outputted to a file?

Upvotes: 2

Views: 77

Answers (1)

Rao
Rao

Reputation: 21379

You have a trivial issue. Since it is using property expansion in the endpoint, it request to expand it.

All you need is to change below statement
From:

testResult.append "\n\nENDPOINT: " +endpoint

To:

testResult.append "\n\nENDPOINT: ${context.expand(endpoint)}" 

Upvotes: 2

Related Questions