Forum Discussion

jmistrik's avatar
jmistrik
Occasional Contributor
13 years ago

test case scope property expansion from different test case

Hello,

I would like to check HttpRequestContent of a rest test resquest step in a specific Test Suite. How can I do the property expansion or get the "expanded" content?

Example:

TestSuite1
- TestCase1
--TestStep1=groovy script that checks the reqest content

TestSuite2
- TestCase2
--TestStep2=REST with request content with property expansion linked to a test case scope property
<Contract>
<a>AAA</a>
<b>${#TestCase#prop1}</b>
</Contract>

I would need to get in TestStep1 the contract after expansion. Could someone help?
The main problem is that i get it as string with the expansion strings (eg. ${#TestCase#prop1}) ..I can call "context.expand()" on the string - that would probably work, but since iam alredy in TestCase1 which has not the properties like the original TestCase2, it does not find them so after expand they are all empty.

Thanks.
Jaroslav)

3 Replies

  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Does this work?

    def requestTestCase = testRunner.testCase.testSuite.project.getTestSuiteByName('TestSuite2').getTestCaseByName('TestCaseTwo')
    def myContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(requestTestCase, null).runContext
    def requestContent = requestTestCase.getTestStepByName('TestStepTwo').httpRequest.requestContent
    return myContext.expand(requestContent)