Forum Discussion
By the way, below solution given by Smartbear staff also works.
Although not as clean as the one I share in other comment but this also works. If I put all the pieces together what is shared in this post, this is what you have to do (Run tested OK - no changes required below. No addition of property at test case level).
- Create a test case (say with name TestCase1).
- Add a groovy script step (say with name Groovy Script1). Add below code here:
import javax.naming.Context
def list = [1,2,3,"adfadfas"]
context.setProperty("list",list)
log.info "from script 1 " + list
3.Add a second groovy script step (say with name Groovy Script2). Add below code here:
import com.eviware.soapui.support.types.StringToObjectMap
def contextMap = new StringToObjectMap( context )
def list1 = contextMap.list
log.info "from script 2" + list1
4. If you want to add another groovy script step (say with name Groovy Script3). Repeat above code:
import com.eviware.soapui.support.types.StringToObjectMap
def contextMap = new StringToObjectMap( context )
def list1 = contextMap.list
log.info "from script 3" + list1
5. Now add a last groovy script to call the above 3 steps (by running the whole test case). Remember to make this step disabled otherwise while running the test case, this step will again call the test case and you will go in a recurring loop. (So Groovy Script4 (disabled)): add below code.
import com.eviware.soapui.support.types.StringToObjectMap
def contextMap = new StringToObjectMap( context )
def tCase = testRunner.testCase.testSuite.testCases["TestCase 1"]
tCase.run(contextMap, false)
6. Now if you run this disabled step, you will see that the array/list from groovy script1 was passed in all other steps.
note: You can also do the same by adding this run groovy script in another test case and run from there.
Hope this helps!
Cheers, Pramod
While posting solutions and helping is great, usually reviving a thread that's this old isn't a good idea.
- PramodYadav9 years agoContributor
Well this was a problem that was bothering us for a very long time and we needed a solution badly to make a good solution design. We could also see many other users struggling with the same problem statement without any concrete answers on internet.
Nonetheless, I was not aware reviving a old thread could be a bad idea. Will explore more on this. Any inputs are also welcome and much appreciated on this matter. Thanks!
- groovyguy9 years agoCommunity Hero
Typically in this instance I would start a new thread outlining the problem again and posting a solution. The end-goal of having an answer to the problem is achieved, and it avoids resurrecting a thread over a year old.
The problem with resurrecting a thread that is old is that the people who originated it may no longer visit the forums, and any further contributions may not be noticed especially since people may not necessarily pay full attention to a thread that old.