SR1
7 years agoOccasional Contributor
List set in Context.setProperty of testSuite modifiable in testCase context but not string,int etc
In soapUI, I have a List in testSuite which I setup using context.setProperty is visible and modifiable in testcase1 and testcase2. I'm able to modify the list in both testcases, but I'm not able to do the same for strings or integers or floats etc. Please see the below code and guide me accordingly. I know that we can use propertyValue to set/change string, but I don't want to use that as my string size is very huge and i have array of such strings.
/*soapUI groovy code:
//In TESTSUITE:
List l=[]
context.setProperty("list",l)
String str="suite"
context.setProperty("string",str)
//In TESTCASE1:
log.info("From TC1")
arrlst=context.getProperty("list")
for(lst in arrlst){
log.info(lst)}
arrlst.add("First added in TC1")
for(lst in arrlst){
log.info(lst)} //prints "First added in TC1"
str=context.getProperty("string")
log.info("The string is"+context.getProperty("string")) //prints "the string is suite"
str="This is TC1!"
log.info("The string is"+context.getProperty("string")) //still prints "the string is suite"
context.setProperty("string",str)
log.info("The string is"+context.getProperty("string")) //prints "the string is this is TC2" but its in TC1's local context
//In TESTCASE2:
log.info("From TC2")
l1=context.getProperty("list")
for(lst in l1){
log.info(lst)} //prints "First added in TC1"
str=context.getProperty("string")
log.info(str) //prints "the string is suite" not the value set in the testcase1
*/
why im able to change/modify the list in other testcases but not the strings, integers etc?