Reputation: 1160
I developed some SoapUI cases which set a property at the start of each test case by reading the properties from a file. This works fine, I can then access each property (lets say propertyA
) by the syntax ${propertyA}
in each test request step.
Now I realized that one of the properties is the same for each test case, so I thought I create a testsuite property for that purpose and remove the property definition from the test case property files. First my test cases all failed, cause now 'propertyA' was not known any more, but I figured out that (according to http://www.soapui.org/Scripting-Properties/property-expansion.html) one solution is to replace each reference to propertyA
by #testSuite#propertyA
.
This is kind of tedious, though, so I thought of creating a groovy script at the beginning of each test case which creates a test case property from the test suite property. According to http://www.soapui.org/Scripting-Properties/tips-a-tricks.html I thought that a script like
def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue("propertyA")
testRunner.testCase.setPropertyValue("propertyA", testSuiteProperty)
should do the job. And if I log.info
the value of testSuiteProperty
this gives indeed the desired value, and also if I assign the testCase property to some variable and log.info
it, it shows the correct value.
However, in the next test step, propertyA
is not known. Just to make sure I tried to use ${#testCase#propertyA}
there, but that is also not known. What did I get wrong here?
Upvotes: 0
Views: 2272
Reputation: 18517
I think your problem is that the t
of testCase
in ${#testCase#propertyA}
must be uppercase: ${#TestCase#propertyA}
. If I add a groovy test step with your code:
def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue("propertyA")
testRunner.testCase.setPropertyValue("propertyA", testSuiteProperty)
And then I add a SOAP test step with follow xml:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:open="http://www.openuri.org/">
<soapenv:Header/>
<soapenv:Body>
<open:procesa>
<open:selector>${#TestCase#propertyA}</open:selector>
</open:procesa>
</soapenv:Body>
</soapenv:Envelope>
It works correctly, however if I use ${#testCase#propertyA}
the property value is not found.
Besides you can check if correct value is used in the raw
tab in the left side of the SOAP test step request. In this tab the request is show with the properties replaced by it's values.
Hope this helps,
Upvotes: 0