0
votes

I've two test case A and B under one test suite

I am setting the context property in script assertion of one of the test step of B

def holder = new XmlHolder( messageExchange.responseContentAsXml )
context.setProperty("xmlHolder", holder)

I am getting the context property in script assertion of one of the test step of A

def Holder=context.getProperty("xmlHolder")
log.info(Holder)

but the value of "Holder" is printed null I just want to set it in one TC and get it in the other one.

EDIT Found this , and I was trying to set property like this. I already had a Runner created in script assertion.

Runner.getTestCase().setPropertyValue("xmlHolder", holder)

But receiving a null error

I could do

Runner.getTestCase().setPropertyValue("xmlHolder", "A")

Just wondering , if TC properties can hold an Object compare to string. So, my original question remains as it is.

1
user1207289, I believe that Runner variable is not available, instead runner is available. In my opinion, soapUI only holds StringToStringMap, so can't hold objects in test case / test suite / project level properties. You may try saving response string directly. Later, read that and convert it to XmlHolder object. - Rao
@Rao Thanks. Can WsdlTestRunContext be used to share context between TC. Got the information on net, but haven't tried it yet. Just thought you might have an idea about it. - user1207289
In script assertion, have below line -context.testCase.testSuite.setPropertyValue('RESPONSE_FOR_LATER_USE', messageExchange.response) - Rao
And use ${#TestSuite#RESPONSE_FOR_LATER_USE} when needed in other locations within the same suite. - Rao
@Rao Get the error No signature of method: com.eviware.soapui.impl.wsdl.WsdlTestSuite.setPropertyValue() is applicable for argument types: (java.lang.String, com.eviware.soapui.impl.wsdl.submit.transports.http.support.attachments.WsdlSinglePartHttpResponse) values: [RESPONSE_FOR_LATER_USE, com.eviware.soapui.impl.wsdl.submit.transports.http.support.attachments.WsdlSinglePartHttpResponse@9ffac9a] Possible solutions: setPropertyValue(java.lang.String, java.lang.String), getPropertyValue(java.lang.String) on setting up the property. - user1207289

1 Answers

0
votes

Based on above comments, got this working

setting property in script assertion of B

context.testCase.testSuite.setPropertyValue('xmlHolder', messageExchange.responseContentAsXml)

getting property in script assertion of B and converting it to XmlHolder object

def HolderContent=context.testCase.testSuite.getPropertyValue('xmlHolder')
def Holder = new XmlHolder ( HolderContent)