Forum Discussion

tgeliot's avatar
tgeliot
Contributor
9 years ago

Using nested property values in a Groovy script

In my TestSuite properties, I have some properties that look like

 

StreamdumpBaseDir            c:/tmp/foo

StreamdumpDir                    ${#TestSuite#StreamdumpBaseDir}/bar

 

I can pass ${#TestSuite#StreamDumpDir} to a RESTful call in the JSON payload and the two levels of interpolation get processed just fine, so that the target web server receives "c:/tmp/foo/bar" as I expect.

 

I would like to use the value of StreamdumpDir in a Groovy script.

I have the following code:

def destDir = testRunner.testCase.testSuite.getPropertyValue( "StreamDumpDir" )

log.info "destDir = $destDir"

 

The result that gets logged is

...destDir = ${#TestSuite#StreamdumpBaseDir}/bar

 

In other words, the embedded property reference doesn't get dereferenced.

Is there a way to fix this, or do I just have to stop using such nested values?

 

Thanks!

 

EDIT:  If one is using SoapUI Pro (i.e. using ReadyAPI), in the Groovy editing window, one can right-click, and from that menu select an option (something like "get data"), and that will lead you into a process of selecting a data item from, e.g. a different test step, and then will automatically generate a Groovy expression that accesses the selected data item.  Pretty slick!

I don't think this is available in regular SoapUI.

  • Have you tried below?
    context.expand('${#TestSuite#StreamdumpDir}')
  • nmrao's avatar
    nmrao
    Champion Level 3
    Have you tried below?
    context.expand('${#TestSuite#StreamdumpDir}')