I am writing a groovy script to use in SOAP UI, that reads through a CSV file of account numbers, then uses the account number in some XML. There will be approximately 5000 account numbers, that I need to loop a SOAP UI test case through.
As the account number can only be used once, my idea is to edit the CSV file and say that line has been used, and then add logic to the Groovy to not use that line again.
I've successfully read the CSV file and looped through it, my specific issue is that I want to set the current row of the CSV to 'Yes' (or any variable will do really :)). I can append to the end of the file, but I need the append to go to a specific row (i.e. the current row of the loop).
I've tried various things like inputFile[rowsData].append("Yes"), I feel I'm very close but not quite there (this is my first time using Groovy and CSVs)
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
wrapUp = groovyUtils.getXmlHolder( "WrapUp#Request" )
import com.eviware.soapui.support.UISupport
import groovy.io.FileType
import org.apache.commons.io.FileUtils
def csvFilePath = "file.csv"
context.fileReader = new BufferedReader(new FileReader(csvFilePath))
def inputFile = new File("file.csv")
rowsData = context.fileReader.readLines()
int rowsize = rowsData.size()
for(int i =0; i < rowsize; i++)
{
rowdata = rowsData[i]
String[] data = rowdata.split(",")
// if the third column is not yes, we haven't used the data
if (data[2].toString() != "YES") {
testRunner.testCase.setPropertyValue("ACCOUNT_NUMBER",data[1])
testRunner.testCase.setPropertyValue("SORT_CODE",data[0])
// this inputs to the end of the csv, needs to go to the current row
inputFile.append("Yes")
break;
}
else
log.info "OUT OF ACCOUNT NUMBERS"
}