0

I am using Ready! API trying to pass a custom variable from an environment into one of the Soap UI NG test cases, however when I set up the property expansion, no value is passed.

I have the following JSON structure:

{
    "password":"password",
    "orgName":"${#Env#orgname}",
    "email":"someuser@notrealdomain.com"
}

When I run the case, the orgname comes back as an empty string, like so

{
    "password":"password",
    "orgName":"",
    "email":"someuser@someorg.com"
}

Thinking maybe I had to move the variable into the TestSuite or something, I added a custom property into the TestSuite and did the same expansion, but again, no value is passed through.

Is this possible to do? Or is there another way to pass an environment custom property?

UPDATE

The answer to this is relatively simple and I may have missed it in the documentation.

When you add a Custom Property to an Environment, it becomes a Custom Property for the Project. So if you need to get the Environment Custom Property value, just do ${#Project#<env_cust_prop>}

Emmanuel F
  • 1,125
  • 1
  • 15
  • 34
  • Are you using ReadyAPI? and taking about environment? or an environment variable in SoapUI are you taking about ? – Rao Jan 09 '17 at 00:11
  • 1
    Ready API with a custom variable in an Environment. I'll clarify the question, thank you. – Emmanuel F Jan 09 '17 at 05:01

2 Answers2

1

The answer to this is relatively simple and I may have missed it in the documentation.

When you add a Custom Property to an Environment, it becomes a Custom Property for the Project. So if you need to get the Environment Custom Property value, just do ${#Project#<env_cust_prop>}

Emmanuel F
  • 1,125
  • 1
  • 15
  • 34
0

This script get the environment variable.

def env = System.getenv()
//Print all the environment variables.

env.each{
log.info it
}
// You can also access the specific variable, say 'username', as show below
String user= env['USERNAME']
//[Code from http://www.mytechtoday.com/2009/01/read-environment-variables-with-groovy.html]

You need to add the activity type Properties in the testCase enter image description here

Create your custom variable for the test case and you add this line in the before script.

testRunner.testCase.testSteps['PROPERTIES_NAME'].setPropertyValue('VARIABLE_NAME',VARIABLE_VALUE);
Roberto Ramos
  • 553
  • 6
  • 16