Forum Discussion
You are correct, an array of values is what I am looking for. Every time I call the API and get a response, I would use the data transfer tool to take the employeeId from the response and add to the next empty row.
EmployeeId | ||
1 | ||
2 | ||
3 | ||
<- Add next employeeId |
I did see the Data Sink tool, where you can specify a target file to store the values in, which I managed to transfer the employeeId to. However, I couldn't see anywhere where I could specify to add the following values to the next empty row. It kept overwriting the previous value.
Any options available I would be happy to look into. Could you explain how I would either store or re-hydrate the data?
Many thanks.
The only way I've found to persist objects throughout the duration of a test is to serialize them to JSON, store that as a test case property, then deserialize back into an object when I need to access it again. Groovy has JSON classes for doing just this, example below:
// Check if list already exists as a property, if not create it String idListStr = context.expand('${#TestCase#idListStr}') List idList if(!idListStr) { idList = new ArrayList() } else { idList = new JsonSlurper().parseText(listStr) } // Add an ID idList.add(someEmployeeId) // Serialize back to JSON idListStr = new JsonBuilder(idList).toString() // Set as a property again testRunner.testCase.setPropertyValue("idListStr", idListStr)