[res] shared Object / Variable (not Property) within a test
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2013
02:01 AM
02-28-2013
02:01 AM
[res] shared Object / Variable (not Property) within a test
Hello,
is there a possibility to share an Object or an Variable within a testRun?
e.g. I have two groovy testSteps and I'm creating in the first step an Object of an own class:
Now I need to access the same (!) Object within the second testStep:
In this case I get following Error message and the TestStep is failed:
[tt:35su6o8z]ERROR:An error occured [No such property: myObject for class: Script3], see error log for details[/tt:35su6o8z]
I don't want to create a new object:
If I try to save this Object at a Property I get only a string containing the reference:
[tt:35su6o8z]soapui.utils.myUtils@2fb5a9d9[/tt:35su6o8z]
Is it possible to use this string to fetch the initial created Object?
Regards Tino
is there a possibility to share an Object or an Variable within a testRun?
e.g. I have two groovy testSteps and I'm creating in the first step an Object of an own class:
def myObject = new soapui.utils.myUtils( context, log)
assert "1st TestStep" == myObject.context.testCase.getName()
Now I need to access the same (!) Object within the second testStep:
????
assert "1st TestStep" == myObject.context.testCase.getName()
In this case I get following Error message and the TestStep is failed:
[tt:35su6o8z]ERROR:An error occured [No such property: myObject for class: Script3], see error log for details[/tt:35su6o8z]
I don't want to create a new object:
def myObject = new soapui.utils.myUtils( context, log)
assert "2ndTestStep" == myObject.context.testCase.getName()
If I try to save this Object at a Property I get only a string containing the reference:
[tt:35su6o8z]soapui.utils.myUtils@2fb5a9d9[/tt:35su6o8z]
Is it possible to use this string to fetch the initial created Object?
Regards Tino
4 REPLIES 4
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2013
02:36 AM
02-28-2013
02:36 AM
Hi Tino,
Thank you for your detailed inquiry.
SoapUI properties only contain strings, so when saving an object to a property what is actually stored is the string representation of the object. Thus, getting your old object is unfortunately not possible.
If you wish, we can create a feature request for this to be implemented.
Regards,
Arian
SmartBear Sweden
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Thank you for your detailed inquiry.
SoapUI properties only contain strings, so when saving an object to a property what is actually stored is the string representation of the object. Thus, getting your old object is unfortunately not possible.
If you wish, we can create a feature request for this to be implemented.
Regards,
Arian
SmartBear Sweden
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2013
04:16 AM
02-28-2013
04:16 AM
To save the string representation of the object inside a property is only one idea to get the same Object state back.
But as I found in a similar thread this is not possible
Another Idea is to save this object reference at a public variable within the testRunner object.
Is there any similar method to achieve this?
pseudo code for 1st TestStep:
pseudo code for 2nd TestStep:
If there is no similar method, it would be nice if you can create a feature request for the implementation of this Methods.
Regards Tino
But as I found in a similar thread this is not possible

Another Idea is to save this object reference at a public variable within the testRunner object.
Is there any similar method to achieve this?
pseudo code for 1st TestStep:
def myObject = new soapui.utils.myUtils( context, log)
testRunner.setObjectReference("myObject", myObject)
assert "1st TestStep" == myObject.context.testCase.getName()
pseudo code for 2nd TestStep:
myObject = testRunner.getObjectReference("myObject")
assert "1st TestStep" == myObject.context.testCase.getName()
If there is no similar method, it would be nice if you can create a feature request for the implementation of this Methods.
Regards Tino
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2013
02:41 AM
03-04-2013
02:41 AM
Hi Tino,
If you want to share objects between TestSteps in the same case, you can simply save them in the test case's context (it has basic Map<Key, Value> functionality), like this:
and then access them in a different test step using
I hope this helps you solve your problem!
Regards,
Arian
SmartBear Sweden
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
If you want to share objects between TestSteps in the same case, you can simply save them in the test case's context (it has basic Map<Key, Value> functionality), like this:
def myObject = new SomeSortOfObject()
context.put("AStringKey", myObject)
and then access them in a different test step using
context.get("AStringKey")
I hope this helps you solve your problem!
Regards,
Arian
SmartBear Sweden
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2013
03:02 AM
03-27-2013
03:02 AM
Great, this is exactly what I want.
Thanks Tino
Thanks Tino
