Forum Discussion

johngregg's avatar
johngregg
New Contributor
12 years ago

Reusing values in setup scripts

Hi all,

I'm using SoapUI 4.5.2 and am trying to create a setup script that will set variables that I reference in my load test. I'm reading test data from files in my setup script. How can I avoid rereading the file on each iteration? For example, if I do 10 runs, then the file is read 10 times. I thought I could read the data into an array and set it on the context, but something isn't working. I'm basing my code on http://www.soapui.org/Load-Testing/load ... pting.html. My relevant part of my script looks like this:


def getTeamMemberData = context.getTeamMemberData //always null!

if (!getTeamMemberData) {
log.info('reading files')
getTeamMemberData = []
def getTeamMemberDataFile = new File(...)
addLanIdsToList = {getTeamMemberData.add(it)}
getTeamMemberDataFile.eachLine(addLanIdsToList)
context.getTeamMemberData = getTeamMemberData
}


"reading files" is printed for every iteration. I think rereading the data file will become a bottleneck for a real load test. What else can I do to stash the data for reuse on subsequent iterations?

thanks
No RepliesBe the first to reply